ricecake
ricecake
is a lightweight framework to build CLI applications in Go.
Features
- Zero dependencies only uses pflag; based on the standard library
- Support for subcommands
- POSIX-compliant flags (short/long flag styles)
- Action-based API (inspired by urfave/cli)
- Init Hook (hook for customizing behavior during CLI initialization)
- Auto-generated help menu!
- Custom banners
- Chainable! (see example)
- Hide commands (see example)
- and more!
Installation
Installing ricecake
is easy, just import:
import "github.com/burntcarrot/ricecake"
Usage
A list of examples:
- Create a basic CLI with ricecake
- CLI with subcommands
- CLI with flags
- CLI built with chaining
- Extract extra arguments passed to CLI
- Hidden commands
- Custom banner
- Nested subcommands
Here is an example on using ricecake
to create CLIs:
package main
import (
"fmt"
"github.com/burntcarrot/ricecake"
)
func main() {
// Create a new CLI.
cli := ricecake.NewCLI("CLI", "CLI with Subcommands", "v0.1.0")
// Set long description for the CLI.
cli.LongDescription("This is an example CLI created with ricecake (contains subcommands).")
// Set the action for the CLI.
cli.Action(func() error {
fmt.Println("I am the root command!")
return nil
})
// Create a new "greet" subcommand.
greet := cli.NewSubCommand("greet", "Greets user.")
// Set the action for the "greet" subcommand.
greet.Action(func() error {
fmt.Println("Hello user!")
return nil
})
// Run the CLI.
cli.Run()
}
License
ricecake
is released under the MIT license. See LICENSE.