https://github.com/openware/kli
Tiny CLI building tools for go apps
https://github.com/openware/kli
Last synced: 8 months ago
JSON representation
Tiny CLI building tools for go apps
- Host: GitHub
- URL: https://github.com/openware/kli
- Owner: openware
- License: mit
- Created: 2023-09-25T09:35:14.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-09-25T10:20:58.000Z (over 2 years ago)
- Last Synced: 2025-07-18T14:53:52.579Z (8 months ago)
- Language: Go
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# A Simple CLI library. Dependency free.
### Features
* Nested Subcommands
* Uses the standard library `flag` package
* Auto-generated help
* Custom banners
* Hidden Subcommands
* Default Subcommand
* Dependency free
### Example
```go
package main
import (
"fmt"
"log"
"github.com/layer-3/neodax/finex/pkg/kli"
)
func main() {
// Create new cli
cli := kli.NewCli("Flags", "A simple example", "v0.0.1")
// Name
name := "Anonymous"
cli.StringFlag("name", "Your name", &name)
// Define action for the command
cli.Action(func() error {
fmt.Printf("Hello %s!\n", name)
return nil
})
if err := cli.Run(); err != nil {
fmt.Printf("Error encountered: %v\n", err)
}
}
```
#### Generated Help
```shell
$ flags --help
Flags v0.0.1 - A simple example
Flags:
-help
Get help on the 'flags' command.
-name string
Your name
```