Documentation
¶
Overview ¶
Package cli defines the Builder type, which allows one to build a CLI application in a modular way.
var builder Builder builder.SetName("myapp") cmd := builder.SetCommand("hello") cmd.SetDescription("Say hello !") cmd.SetAction(func(flags Flags) error { fmt.Printf("Hello %s!\n", flags.String("dude")) }) builder.Build().Run(os.Args)
An implementation of the builder is free to provide primitives to create more complex action.
Documentation Last Review: 13.10.2020
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Application ¶
Application is the main interface to run the CLI.
type BoolFlag ¶
BoolFlag is a definition of a command flag expected to be parsed as a boolean.
- implements cli.Flag
type Builder ¶
type Builder interface { Provider // Build returns the application. Build() Application }
Builder is an application builder interface. One can set properties of an application then build it.
type CommandBuilder ¶
type CommandBuilder interface { // SetDescription sets the value of the description for this command. SetDescription(value string) // SetFlags sets the flags for this command. SetFlags(...Flag) // SetAction sets the action for this command. SetAction(Action) // SetSubCommand creates a subcommand for this command. SetSubCommand(name string) CommandBuilder }
CommandBuilder is a command builder interface. One can set properties of a specific command like its name and description and what it should do when invoked.
type DurationFlag ¶
DurationFlag is a definition of a command flag expected to be parsed as a duration.
- implements cli.Flag
type Flags ¶
type Flags interface { String(name string) string StringSlice(name string) []string Duration(name string) time.Duration Path(name string) string Int(name string) int Bool(name string) bool }
Flags provides the primitives to an action to read the flags.
type Initializer ¶
type Initializer interface { // SetCommands if the function called by the builder to add the modules' // commands. The modules implement this function and use the provided // provider to create its specific commands. SetCommands(Provider) }
Initializer defines a primitive for modules to add their commands. A cli will gather all the initializers from each desired modules and call the SetCommands for each of them.
type IntFlag ¶
IntFlag is a definition of a command flag expected to be parsed as a integer.
- implements cli.Flag
type Provider ¶
type Provider interface { // SetCommand creates a new command with the given name and returns its // builder. SetCommand(name string) CommandBuilder }
Provider defines a primitive for modules to provide their commands
type StringFlag ¶
StringFlag is a definition of a command flag expected to be parsed as a string.
- implements cli.Flag
type StringSliceFlag ¶
StringSliceFlag is a definition of a command flag expected to tbe parsed as a slice of strings.
- implements cli.Flag
Directories
¶
Path | Synopsis |
---|---|
Package main provides a cli for crypto operations like generating keys or displaying specific key formats.
|
Package main provides a cli for crypto operations like generating keys or displaying specific key formats. |
Package node defines the Builder type, which builds an CLI application to controle a node.
|
Package node defines the Builder type, which builds an CLI application to controle a node. |
memcoin
Package main implements a ledger based on in-memory components.
|
Package main implements a ledger based on in-memory components. |
Package ucli provides a cli builder implementation based on the urfave/cli library.
|
Package ucli provides a cli builder implementation based on the urfave/cli library. |