adamveld12 / commando

:computer: A simple, low friction way to build CLIs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Commando

GoDoc Go Walker Gocover Go Report Card

wercker status

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

How to use

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

License

MIT

About

:computer: A simple, low friction way to build CLIs

License:MIT License


Languages

Language:Go 100.0%