mole is a wrapper of exec.Cmd suite for executing piped commands.
import "github.com/kagemiku/mole"
mole := mole.NewMole()
- Mole.Output()
mole := mole.NewMole()
mole.Add("ls", "-la")
mole.Add("head", "-5")
mole.Add("wc", "-l")
mole.Add("tr", "-d", " ")
out, err := mole.Output()
if err != nil {
log.Fatal(err)
}
fmt.Println(string(out))
- Mole.Run()
mole := mole.NewMole()
mole.Add("wc", "-c")
var buf bytes.Buffer
buf.WriteString("hoge")
mole.Stdin = &buf
mole.Stdout = os.Stdout
if err := mole.Run(); err != nil {
log.Fatal(err)
}
MIT License
kagemiku