# README
= CLI
Struct-based CLI library for Go
== Status
This project is alpha. It lacks in documentation, testing and featres. It's out for feedback and bug reports. Expect bugs and breaking changes.
== Example
[source,go]
package main
import ( "context" "fmt" "log"
"github.com/thegrumpylion/cli"
)
type rootCmd struct { Host string Port int }
func (c *rootCmd) Run(ctx context.Context) error { fmt.Println(c.Host, c.Port) return nil }
func main() { c := &rootCmd{}
if err := cli.ParseCommandAndExecute(context.Background(), c); err != nil {
log.Fatalln("error:", err)
}
}
[source,sh]
./cmd --host localhost --port 8080
localhost 8080
Or
[source,sh]
./cmd --host=localhost --port=8080
localhost 8080
=== Help
[source,sh]
./cmd --help
Usage: cmd [--host HOST] [--port PORT]
Flags:
--host
--port
=== Completion