yacli
is an open source command line tool written in GoLang
that allows developers to easily create powerful and customizable command line interfaces (CLIs
) for their applications.
With yacli
, you can quickly build interactive CLI
applications that are easy to use and provide a rich user experience.
yacli
comes with a simple and intuitive API
that makes it easy to define commands, flags, and arguments for your CLI
.
You can create subcommands, and define flags with short and long names.
yacli
also supports various types of flags, such as boolean, string, integer, float and provides built-in support for input validation and error handling.
Commands do not require the use of global variables or init()
function.
Just declaratively describe your command and let yacli
do the rest.
Validation comes by default - you can take a break from arguments and flags validation.
Verbose help message is already shipped.
The first step is to install yacli on your system. You can do this by running the following command:
$ go get github.com/dkharms/yacli
var root = yacli.NewRootCommand(
yacli.WithCommandDescription("Just prints <message> in format you specified"),
yacli.WithMutualExclusiveFlags(
yacli.NewFlag("uppercase", "u", "Print <message> in uppercase", yacli.Bool),
yacli.NewFlag("lowercase", "l", "Print <message> in lowercase", yacli.Bool),
),
yacli.WithArguments(
yacli.NewArgument("message", "Message to print", yacli.String),
yacli.NewArgument("amount", "Print <message> `n` times", yacli.Integer),
),
yacli.WithAction(echo),
)
func echo(ctx yacli.Context) error { … }
Once you have defined your CLI commands, you can build and run your application using the following commands:
$ go build
$ ./echo --uppercase true "I love Computer Science" 2
$ I LOVE COMPUTER SCIENCE
$ I LOVE COMPUTER SCIENCE