Nice is a highly customizable and lightweight framework for crafting CLI apps.
Nice respects idiomatic Go code and focuses to be clear, efficient and easy to write and maintain.
You can use it as a full-featured non-opinionated framework or use any nice packages as stand-alone libraries.
I hope you'll enjoy your nice CLI app!
Let's start with your first Nice CLI app.
First, install the framework:
$ go get github.com/SuperPaintman/nice/cli
Then put this code into a file (hello.go
for example):
package main
import "github.com/SuperPaintman/nice/cli"
func main() {
app := cli.App{
Name: "hello",
Usage: cli.Usage("Print a friendly greeting"),
Action: cli.ActionFunc(func(cmd *cli.Command) cli.ActionRunner {
name := cli.StringArg(cmd, "name",
cli.Usage("Who we say hello to"),
cli.Optional,
)
*name = "Nice" // Default value.
return func(cmd *cli.Command) error {
cmd.Printf("Hello, %s!\n", *name)
return nil
}
}),
CommandFlags: []cli.CommandFlag{
cli.HelpCommandFlag(),
cli.VersionCommandFlag("0.0.0"),
},
}
app.HandleError(app.Run())
}
Now you can run it!
$ go run . world
Or print the help for your app:
$ go run . -h
You can find more examples in the ./examples
directory.
Documentation โข Source
import "github.com/SuperPaintman/nice/cli"
Documentation โข Source
import "github.com/SuperPaintman/nice/colors"
$ go test -race ./...
$ go test ./... -bench=. -benchmem -run='^Benckmark'
- flag Go
- github.com/spf13/cobra Go
- github.com/urfave/cli Go
- github.com/fatih/color Go
- github.com/c-bata/go-prompt Go
- github.com/muesli/termenv Go
- github.com/alecthomas/kingpin Go
- npmjs.com/package/ervy JavaScript
- npmjs.com/package/commander JavaScript
- npmjs.com/package/chalk JavaScript
- npmjs.com/package/inquirer JavaScript
- npmjs.com/package/prompts JavaScript
- npmjs.com/package/ora JavaScript
- npmjs.com/package/clui JavaScript
With ๐ซ by Aleksandr Krivoshchekov (@SuperPaintman)