Skip to content

Latest commit

 

History

History
46 lines (37 loc) · 752 Bytes

README.md

File metadata and controls

46 lines (37 loc) · 752 Bytes

mole

Build Status

mole is a wrapper of exec.Cmd suite for executing piped commands.

Usage

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)
}

License

MIT License

Author

kagemiku