acmd
TODO
Rationale
TODO.
Features
- Simple API.
- Easy to integrate.
- Builtin
help
andversion
commands. - Clean and tested code.
- Dependency-free.
Install
Go version 1.17+
go get github.com/cristalhq/acmd
Example
cmds := []acmd.Command{
{
Name: "now",
Description: "prints current time",
Do: func(ctx context.Context, args []string) error {
fmt.Printf("now: %s\n", now.Format("15:04:05"))
return nil
},
},
{
Name: "status",
Description: "prints status of the system",
Do: func(ctx context.Context, args []string) error {
// do something with ctx :)
return nil
},
},
}
// all the acmd.Config fields are optional
r := acmd.RunnerOf(cmds, acmd.Config{
AppName: "acmd-example",
AppDescription: "Example of acmd package",
Version: "the best v0.x.y",
// Context - if nil `signal.Notify` will be used
// Args - if nil `os.Args[1:]` will be used
// Usage - if nil default print will be used
})
if err := r.Run(); err != nil {
panic(err)
}
Also see examples: examples_test.go.
Documentation
See these docs.