Skip to content

kagemiku/mole

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

execute piped command easily in golang

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages