Categorygithub.com/urfave/cli
modulepackage
1.22.16
Repository: https://github.com/urfave/cli.git
Documentation: pkg.go.dev

# README

cli

Run Tests Go Reference Go Report Card codecov

cli is a simple, fast, and fun package for building command line apps in Go. The goal is to enable developers to write fast and distributable command line applications in an expressive way.

Usage Documentation

Usage documentation for v1 is available at the docs site or in-tree at ./docs/v1/manual.md

Installation

Make sure you have a working Go environment. Go version 1.18+ is supported.

Supported platforms

cli is tested against multiple versions of Go on Linux, and against the latest released version of Go on OS X and Windows. For full details, see ./.github/workflows/cli.yml.

Build tags

You can use the following build tags:

urfave_cli_no_docs

When set, this removes ToMarkdown and ToMan methods, so your application won't be able to call those. This reduces the resulting binary size by about 300-400 KB (measured using Go 1.18.1 on Linux/amd64), due to less dependencies.

Using v1 releases

$ go get github.com/urfave/cli
...
import (
  "github.com/urfave/cli"
)
...

# Packages

No description provided by the author

# Functions

DefaultAppComplete prints the list of subcommands as the default app completion method.
No description provided by the author
HandleAction attempts to figure out which Action signature was used.
HandleExitCoder checks if the error fulfills the ExitCoder interface, and if so prints the error to stderr (if it is non-empty) and calls OsExiter with the given exit code.
NewApp creates a new cli Application with some reasonable defaults for Name, Usage, Version and Action.
NewContext creates a new context.
NewExitError makes a new *ExitError.
NewMultiError creates a new MultiError.
ShowAppHelp is an action that displays the help.
ShowAppHelpAndExit - Prints the list of subcommands for the app and exits with exit code.
ShowCommandCompletions prints the custom completions for a given command.
ShowCommandHelp prints help for the given command.
ShowCommandHelpAndExit - exits with code after showing help.
ShowCompletions prints the lists of commands within a given context.
ShowSubcommandHelp prints help for the given subcommand.
ShowVersion prints the version number of the App.

# Variables

AppHelpTemplate is the text template for the Default help topic.
BashCompletionFlag enables bash-completion for all commands and subcommands.
CommandHelpTemplate is the text template for the command help topic.
ErrWriter is used to write errors to the user.
No description provided by the author
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.
HelpFlag prints the help for all commands and subcommands Set to the zero value (BoolFlag{}) to disable flag -- keeps subcommand unless HideHelp is set to true).
HelpPrinter is a function that writes the help output.
HelpPrinterCustom is a function that writes the help output.
No description provided by the author
OsExiter is the function used when the app exits.
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

App is the main structure of a cli application.
Author represents someone who has contributed to a cli project.
BoolFlag is a flag with type bool.
BoolTFlag is a flag with type bool that is true by default.
Command is a subcommand for a cli.App.
CommandCategory is a category containing commands.
Context is a type that is passed through to each Handler action in a cli application.
DurationFlag is a flag with type time.Duration (see https://golang.org/pkg/time/#ParseDuration).
ExitError fulfills both the builtin `error` interface and `ExitCoder`.
Float64Flag is a flag with type float64.
GenericFlag is a flag with type Generic.
Int64Flag is a flag with type int64.
Int64SliceFlag is a flag with type *Int64Slice.
IntFlag is a flag with type int.
IntSliceFlag is a flag with type *IntSlice.
MultiError is an error that wraps multiple errors.
StringFlag is a flag with type string.
StringSliceFlag is a flag with type *StringSlice.
Uint64Flag is a flag with type uint64.
UintFlag is a flag with type uint.

# Interfaces

DocGenerationFlag is an interface that allows documentation generation for the flag.
No description provided by the author
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.
Generic is a generic parseable type identified by a specific flag.
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.

# Type aliases

ActionFunc is the action to execute when no subcommands are specified.
AfterFunc is an action to execute after any subcommands are run, but after the subcommand has finished it is run even if Action() panics.
Args contains apps console arguments.
BashCompleteFunc is an action to execute when the bash-completion flag is set.
BeforeFunc is an action to execute before any subcommands are run, but after the context is ready if a non-nil error is returned, no subcommands are run.
CommandCategories is a slice of *CommandCategory.
CommandNotFoundFunc is executed if the proper command cannot be found.
Commands is a slice of Command.
No description provided by the author
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.
Int64Slice is an opaque type for []int to satisfy flag.Value and flag.Getter.
IntSlice is an opaque type for []int to satisfy flag.Value and flag.Getter.
OnUsageErrorFunc is executed if an usage error occurs.
StringSlice is an opaque type for []string to satisfy flag.Value and flag.Getter.