https://github.com/berquerant/fcli
utilities for function-based command-line tools
https://github.com/berquerant/fcli
go
Last synced: about 1 year ago
JSON representation
utilities for function-based command-line tools
- Host: GitHub
- URL: https://github.com/berquerant/fcli
- Owner: berquerant
- License: mit
- Created: 2022-05-02T15:21:21.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-07-18T07:56:28.000Z (almost 4 years ago)
- Last Synced: 2025-02-06T16:58:40.708Z (over 1 year ago)
- Topics: go
- Language: Go
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fcli
Package fcli provides utilities for function-based command-line tools.
## Usage
``` go
package main
import (
"fmt"
"github.com/berquerant/fcli"
)
func greet(name string) {
fmt.Println("Hello,", name)
}
// bye prints Bye!
func bye() {
fmt.Println("Bye!")
}
func main() {
cli := fcli.NewCLI("do")
_ = cli.Add(greet)
_ = cli.Add(bye)
_ = cli.Start()
}
```
```
❯ ./do
Error: not enough arguments
Usage: do {bye,greet}
❯ ./do greet -h
Usage of greet:
-name string
❯ ./do greet -name world
Hello, world
❯ ./do bye -h
bye prints Bye!
❯ ./do bye
Bye!
```
## Examples
[examples](./examples/)