goshell
Small cli for Go
Example of use
package main
import "goshell"
import "fmt"
func echo(params ...string) error {
fmt.Println(params)
return nil
}
func hello(params ...string) error {
fmt.Print("Hi")
if len(params) >= 1 {
fmt.Printf(" %s", params[0])
}
fmt.Printf("!\n")
return nil
}
func main() {
var (
shell goshell.Shell
notifyEnd chan bool
)
notifyEnd = make(chan bool)
shell = goshell.NewDefaultShell()
shell.RegistrerCommand("echo", echo)
shell.RegistrerCommand("hello", hello)
go goshell.Run(shell, notifyEnd)
<-notifyEnd
}