Go to file
2016-08-02 15:37:08 +02:00
main.go initial 2016-08-02 15:31:30 +02:00
README.md updated README.md 2016-08-02 15:37:08 +02:00

b2e

simple tool to translate bash scripts to embedded go commands

usage

b2e -s="source path" -d="destination file"

default values are

s = "."

d = ".\bash.go"

licence

MIT

Author

Darko Luketic

Example Output

package bash

import (
	"os"
	"os/exec"
)

func DiskusageCommand() error {
	cmd := exec.Command("du", "-h")
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	if e := cmd.Start(); e != nil {
		return e
	}
	if e := cmd.Wait(); e != nil {
		return e
	}

	cmd = exec.Command("mkdir", "-p", "/var/lib/go")
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	if e := cmd.Start(); e != nil {
		return e
	}
	if e := cmd.Wait(); e != nil {
		return e
	}

	cmd = exec.Command("go", "get", "-u")
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	if e := cmd.Start(); e != nil {
		return e
	}
	if e := cmd.Wait(); e != nil {
		return e
	}
    return nil
}

func ListCommand() error {
	cmd := exec.Command("ls", "-lah")
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	if e := cmd.Start(); e != nil {
		return e
	}
	if e := cmd.Wait(); e != nil {
		return e
	}

	cmd = exec.Command("df", "-h")
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	if e := cmd.Start(); e != nil {
		return e
	}
	if e := cmd.Wait(); e != nil {
		return e
	}
    return nil
}