Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mivinci/cli
A fast lightweight Go package to build your command line apps.
https://github.com/mivinci/cli
cli command-line-interface
Last synced: 11 days ago
JSON representation
A fast lightweight Go package to build your command line apps.
- Host: GitHub
- URL: https://github.com/mivinci/cli
- Owner: mivinci
- License: apache-2.0
- Created: 2023-01-26T15:43:11.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-23T23:38:57.000Z (over 1 year ago)
- Last Synced: 2024-10-11T05:43:48.053Z (about 1 month ago)
- Topics: cli, command-line-interface
- Language: Go
- Homepage:
- Size: 17.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cli
A package for building command line apps. It looks like [spf13/cobra](https://github.com/spf13/cobra) but has [urfave/cli](https://github.com/urfave/cli)-like APIs and a builtin argument parser also.
## Features
- POSIX-like syntax
- Nested commands
- Positional arguments
- Type-safe flag values
- Minimal (no duplicated flags defined with std/flag)
- Lightweight (no other packages are needed)
- Pluggable config file watcher (TODO)## Supported flag types
- int, uint
- bool
- string
- time.Duration
- net.IP## Usage
### Installation
```bash
go get -u github.com/mivinci/cli
```### Quickstart
Here's a simple helloworld example.
```go
import (
"os""github.com/mivinci/cli"
)var cmd = cli.Command{
Name: "hello",
Usage: "A helloworld command line app.",
Args: []string{"name"},
Run: func(ctx *cli.Context) error {
println("Hello,", ctx.Args()[0])
return nil
},
}func main() {
cmd.Exec(os.Args)
}
```Compile and run with `-h`, the output will be as follows.
```
$ go run hello.go -h
A helloworld command line app.Usage:
hello [option]*Available options:
-h, --help show help messageUse "hello [command] --help" for more infomation about a command.
```Checkout [example](./example) for details.
## Feedbacks
- [Issues](https://github.com/mivinci/cli/issues)
## License
mivinci/cli is Apache 2.0 licensed.