Categorygithub.com/urfave/cli/v3
modulepackage
3.0.0-beta1
Repository: https://github.com/urfave/cli.git
Documentation: pkg.go.dev

# README

Welcome to urfave/cli

Go Reference Go Report Card codecov Tests status

urfave/cli is a declarative, simple, fast, and fun package for building command line tools in Go featuring:

  • commands and subcommands with alias and prefix match support
  • flexible and permissive help system
  • dynamic shell completion for bash, zsh, fish, and powershell
  • no dependencies except Go standard library
  • input flags for simple types, slices of simple types, time, duration, and others
  • compound short flag support (-a -b -c can be shortened to -abc)
  • documentation generation in man and Markdown (supported via the urfave/cli-docs module)
  • input lookup from:
    • environment variables
    • plain text files
    • structured file formats (supported via the urfave/cli-altsrc module)

Documentation

See the hosted documentation website at https://cli.urfave.org. Contents of this website are built from the ./docs directory.

Support

Check the Q&A discussions. If you don't find answer to your question, create a new discussion.

If you found a bug or have a feature request, create a new issue.

Please keep in mind that this project is run by unpaid volunteers.

License

See LICENSE.

# Packages

# Functions

DefaultAppComplete prints the list of subcommands as the default app completion method.
EnvVars is a helper function to encapsulate a number of envVarValueSource together as a ValueSourceChain.
Exit wraps a message and exit code into an error, which by default is handled with a call to os.Exit during default error handling.
Files is a helper function to encapsulate a number of fileValueSource together as a ValueSourceChain.
HandleExitCoder handles errors implementing ExitCoder by printing their message and calling OsExiter with the given exit code.
NewMapBase makes a *MapBase with default values.
NewSliceBase makes a *SliceBase with default values.
ShowAppHelp is an action that displays the help.
ShowAppHelpAndExit - Prints the list of subcommands for the app and exits with exit code.
ShowCommandHelp prints help for the given command.
ShowCommandHelpAndExit - exits with code after showing help.
ShowSubcommandHelp prints help for the given subcommand.
ShowSubcommandHelpAndExit - Prints help for the given subcommand and exits with exit code.
ShowVersion prints the version number of the App.

# Variables

AnyArguments to differentiate between no arguments(nil) vs aleast one.
CommandHelpTemplate is the text template for the command help topic.
ErrWriter is used to write errors to the user.
FlagEnvHinter annotates flag help message with the environment variable details.
FlagFileHinter annotates flag help message with the environment variable details.
FlagNamePrefixer converts a full flag name and its placeholder into the help message flag prefix.
FlagStringer converts a flag definition to a string.
GenerateShellCompletionFlag enables shell completion.
HelpFlag prints the help for all commands and subcommands.
HelpPrinter is a function that writes the help output.
HelpPrinterCustom is a function that writes the help output.
OsExiter is the function used when the app exits.
RootCommandHelpTemplate is the text template for the Default help topic.
SubcommandHelpTemplate is the text template for the subcommand help topic.
VersionFlag prints the version for the application.
VersionPrinter prints the version for the App.

# Structs

BoolConfig defines the configuration for bool flags.
Command contains everything needed to run an application that accepts a string slice of arguments such as os.Args.
FlagBase [T,C,VC] is a generic flag base which can be used as a boilerplate to implement the most common interfaces used by urfave/cli.
IntegerConfig is the configuration for all integer type flags.
MapBase wraps map[string]T to satisfy flag.Value.
MutuallyExclusiveFlags defines a mutually exclusive flag group Multiple option paths can be provided out of which only one can be defined on cmdline So for example [ --foo | [ --bar something --darth somethingelse ] ].
NoConfig is for flags which dont need a custom configuration.
SliceBase wraps []T to satisfy flag.Value.
StringConfig defines the configuration for string flags.
TimestampConfig defines the config for timestamp flags.
ValueSourceChain contains an ordered series of ValueSource that allows for lookup where the first ValueSource to resolve is returned.

# Interfaces

ActionableFlag is an interface that wraps Flag interface and RunAction operation.
CategorizableFlag is an interface that allows us to potentially use a flag in a categorized representation.
CommandCategories interface allows for category manipulation.
CommandCategory is a category containing commands.
Countable is an interface to enable detection of flag values which support repetitive flags.
DocGenerationFlag is an interface that allows documentation generation for the flag.
DocGenerationMultiValueFlag extends DocGenerationFlag for slice/map based flags.
EnvValueSource is to specifically detect env sources when printing help text.
ErrorFormatter is the interface that will suitably format the error output.
ExitCoder is the interface checked by `App` and `Command` for a custom exit code.
Flag is a common interface related to parsing flags in cli.
FlagCategories interface allows for category manipulation.
LocalFlag is an interface to enable detection of flags which are local to current command.
MapSource is a source which can be used to look up a value based on a key typically for use with a cli.Flag.
MultiError is an error that wraps multiple errors.
RequiredFlag is an interface that allows us to mark flags as required it allows flags required flags to be backwards compatible with the Flag interface.
Serializer is used to circumvent the limitations of flag.FlagSet.Set.
Value represents a value as used by cli.
ValueCreator is responsible for creating a flag.Value emulation as well as custom formatting T specifies the type C specifies the config for the type.
ValueSource is a source which can be used to look up a value, typically for use with a cli.Flag.
VisibleFlag is an interface that allows to check if a flag is visible.
VisibleFlagCategory is a category containing flags.

# Type aliases

ActionFunc is the action to execute when no subcommands are specified.
AfterFunc is an action that executes after any subcommands are run and have finished.
BeforeFunc is an action that executes prior to any subcommands being run once the context is ready.
CommandNotFoundFunc is executed if the proper command cannot be found.
ExitErrHandlerFunc is executed if provided in order to handle exitError values returned by Actions and Before/After functions.
FlagEnvHintFunc is used by the default FlagStringFunc to annotate flag help with the environment variable details.
FlagFileHintFunc is used by the default FlagStringFunc to annotate flag help with the file path details.
FlagNamePrefixFunc is used by the default FlagStringFunc to create prefix text for a flag's full name.
FlagsByName is a slice of Flag.
FlagStringFunc is used by the help generation to display a flag, which is expected to be a single line.
InvalidFlagAccessFunc is executed when an invalid flag is accessed from the context.
OnUsageErrorFunc is executed if a usage error occurs.
ShellCompleteFunc is an action to execute when the shell completion flag is set.