A simple bare bones CLI helper.
Features include:
- Auto parses arguments to the right type for your handlers
- Free help text/usages output using
help | h | --help
func main(){
app := commando.New()
app.Add(add, "adds any 2 numbers", "add", "sum")
app.Add(sayhello, "greets you", "hello", "hi")
app.Add(hotOrNot, "do you think this is hot?", "hot")
app.Execute(os.Args[1:]...)
// or any of the following:
// app.Execute("add", "2", "3")
// app.Execute("hello", "Steve")
// app.Execute("sum", "1", "2")
// app.Execute("ho", "false")
}
func hotOrNot(hot bool){
if hot {
fmt.Println("this cli is so hot")
} else {
fmt.Println("this cli is so not :(")
}
}
func sayHello(name string) {
fmt.Printf("Hello, %s!\n", name)
}
func add(a, b int){
fmt.Printf("%d\n", a + b)
}
MIT