| 1 |
package cli // import "github.com/urfave/cli/v2" |
| 2 |
|
| 3 |
Package cli provides a minimal framework for creating and organizing command |
| 4 |
line Go applications. cli is designed to be easy to understand and write, |
| 5 |
the most simple cli application can be written as follows: |
| 6 |
|
| 7 |
func main() { |
| 8 |
(&cli.App{}).Run(os.Args) |
| 9 |
} |
| 10 |
|
| 11 |
Of course this application does not do much, so let's make this an actual |
| 12 |
application: |
| 13 |
|
| 14 |
func main() { |
| 15 |
app := &cli.App{ |
| 16 |
Name: "greet", |
| 17 |
Usage: "say a greeting", |
| 18 |
Action: func(c *cli.Context) error { |
| 19 |
fmt.Println("Greetings") |
| 20 |
return nil |
| 21 |
}, |
| 22 |
} |
| 23 |
|
| 24 |
app.Run(os.Args) |
| 25 |
} |
| 26 |
|
| 27 |
VARIABLES |
| 28 |
|
| 29 |
var ( |
| 30 |
SuggestFlag SuggestFlagFunc = nil // initialized in suggestions.go unless built with urfave_cli_no_suggest |
| 31 |
SuggestCommand SuggestCommandFunc = nil // initialized in suggestions.go unless built with urfave_cli_no_suggest |
| 32 |
SuggestDidYouMeanTemplate string = suggestDidYouMeanTemplate |
| 33 |
) |
| 34 |
var AppHelpTemplate = `NAME: |
| 35 |
{{template "helpNameTemplate" .}} |
| 36 |
|
| 37 |
USAGE: |
| 38 |
{{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}}{{if .ArgsUsage}} {{.ArgsUsage}}{{else}}{{if .Args}} [arguments...]{{end}}{{end}}{{end}}{{if .Version}}{{if not .HideVersion}} |
| 39 |
|
| 40 |
VERSION: |
| 41 |
{{.Version}}{{end}}{{end}}{{if .Description}} |
| 42 |
|
| 43 |
DESCRIPTION: |
| 44 |
{{template "descriptionTemplate" .}}{{end}} |
| 45 |
{{- if len .Authors}} |
| 46 |
|
| 47 |
AUTHOR{{template "authorsTemplate" .}}{{end}}{{if .VisibleCommands}} |
| 48 |
|
| 49 |
COMMANDS:{{template "visibleCommandCategoryTemplate" .}}{{end}}{{if .VisibleFlagCategories}} |
| 50 |
|
| 51 |
GLOBAL OPTIONS:{{template "visibleFlagCategoryTemplate" .}}{{else if .VisibleFlags}} |
| 52 |
|
| 53 |
GLOBAL OPTIONS:{{template "visibleFlagTemplate" .}}{{end}}{{if .Copyright}} |
| 54 |
|
| 55 |
COPYRIGHT: |
| 56 |
{{template "copyrightTemplate" .}}{{end}} |
| 57 |
` |
| 58 |
AppHelpTemplate is the text template for the Default help topic. cli.go |
| 59 |
uses text/template to render templates. You can render custom help text by |
| 60 |
setting this variable. |
| 61 |
|
| 62 |
var CommandHelpTemplate = `NAME: |
| 63 |
{{template "helpNameTemplate" .}} |
| 64 |
|
| 65 |
USAGE: |
| 66 |
{{template "usageTemplate" .}}{{if .Category}} |
| 67 |
|
| 68 |
CATEGORY: |
| 69 |
{{.Category}}{{end}}{{if .Description}} |
| 70 |
|
| 71 |
DESCRIPTION: |
| 72 |
{{template "descriptionTemplate" .}}{{end}}{{if .VisibleFlagCategories}} |
| 73 |
|
| 74 |
OPTIONS:{{template "visibleFlagCategoryTemplate" .}}{{else if .VisibleFlags}} |
| 75 |
|
| 76 |
OPTIONS:{{template "visibleFlagTemplate" .}}{{end}} |
| 77 |
` |
| 78 |
CommandHelpTemplate is the text template for the command help topic. cli.go |
| 79 |
uses text/template to render templates. You can render custom help text by |
| 80 |
setting this variable. |
| 81 |
|
| 82 |
var ErrWriter io.Writer = os.Stderr |
| 83 |
ErrWriter is used to write errors to the user. This can be anything |
| 84 |
implementing the io.Writer interface and defaults to os.Stderr. |
| 85 |
|
| 86 |
var FishCompletionTemplate = `# {{ .App.Name }} fish shell completion |
| 87 |
|
| 88 |
function __fish_{{ .App.Name }}_no_subcommand --description 'Test if there has been any subcommand yet' |
| 89 |
for i in (commandline -opc) |
| 90 |
if contains -- $i{{ range $v := .AllCommands }} {{ $v }}{{ end }} |
| 91 |
return 1 |
| 92 |
end |
| 93 |
end |
| 94 |
return 0 |
| 95 |
end |
| 96 |
|
| 97 |
{{ range $v := .Completions }}{{ $v }} |
| 98 |
{{ end }}` |
| 99 |
var MarkdownDocTemplate = `{{if gt .SectionNum 0}}% {{ .App.Name }} {{ .SectionNum }} |
| 100 |
|
| 101 |
{{end}}# NAME |
| 102 |
|
| 103 |
{{ .App.Name }}{{ if .App.Usage }} - {{ .App.Usage }}{{ end }} |
| 104 |
|
| 105 |
# SYNOPSIS |
| 106 |
|
| 107 |
{{ .App.Name }} |
| 108 |
{{ if .SynopsisArgs }} |
| 109 |
` + "```" + ` |
| 110 |
{{ range $v := .SynopsisArgs }}{{ $v }}{{ end }}` + "```" + ` |
| 111 |
{{ end }}{{ if .App.Description }} |
| 112 |
# DESCRIPTION |
| 113 |
|
| 114 |
{{ .App.Description }} |
| 115 |
{{ end }} |
| 116 |
**Usage**: |
| 117 |
|
| 118 |
` + "```" + `{{ if .App.UsageText }} |
| 119 |
{{ .App.UsageText }} |
| 120 |
{{ else }} |
| 121 |
{{ .App.Name }} [GLOBAL OPTIONS] command [COMMAND OPTIONS] [ARGUMENTS...] |
| 122 |
{{ end }}` + "```" + ` |
| 123 |
{{ if .GlobalArgs }} |
| 124 |
# GLOBAL OPTIONS |
| 125 |
{{ range $v := .GlobalArgs }} |
| 126 |
{{ $v }}{{ end }} |
| 127 |
{{ end }}{{ if .Commands }} |
| 128 |
# COMMANDS |
| 129 |
{{ range $v := .Commands }} |
| 130 |
{{ $v }}{{ end }}{{ end }}` |
| 131 |
var OsExiter = os.Exit |
| 132 |
OsExiter is the function used when the app exits. If not set defaults to |
| 133 |
os.Exit. |
| 134 |
|
| 135 |
var SubcommandHelpTemplate = `NAME: |
| 136 |
{{template "helpNameTemplate" .}} |
| 137 |
|
| 138 |
USAGE: |
| 139 |
{{template "usageTemplate" .}}{{if .Category}} |
| 140 |
|
| 141 |
CATEGORY: |
| 142 |
{{.Category}}{{end}}{{if .Description}} |
| 143 |
|
| 144 |
DESCRIPTION: |
| 145 |
{{template "descriptionTemplate" .}}{{end}}{{if .VisibleCommands}} |
| 146 |
|
| 147 |
COMMANDS:{{template "visibleCommandCategoryTemplate" .}}{{end}}{{if .VisibleFlagCategories}} |
| 148 |
|
| 149 |
OPTIONS:{{template "visibleFlagCategoryTemplate" .}}{{else if .VisibleFlags}} |
| 150 |
|
| 151 |
OPTIONS:{{template "visibleFlagTemplate" .}}{{end}} |
| 152 |
` |
| 153 |
SubcommandHelpTemplate is the text template for the subcommand help topic. |
| 154 |
cli.go uses text/template to render templates. You can render custom help |
| 155 |
text by setting this variable. |
| 156 |
|
| 157 |
var VersionPrinter = printVersion |
| 158 |
VersionPrinter prints the version for the App |
| 159 |
|
| 160 |
var HelpPrinter helpPrinter = printHelp |
| 161 |
HelpPrinter is a function that writes the help output. If not set |
| 162 |
explicitly, this calls HelpPrinterCustom using only the default template |
| 163 |
functions. |
| 164 |
|
| 165 |
If custom logic for printing help is required, this function can be |
| 166 |
overridden. If the ExtraInfo field is defined on an App, this function |
| 167 |
should not be modified, as HelpPrinterCustom will be used directly in order |
| 168 |
to capture the extra information. |
| 169 |
|
| 170 |
var HelpPrinterCustom helpPrinterCustom = printHelpCustom |
| 171 |
HelpPrinterCustom is a function that writes the help output. It is used as |
| 172 |
the default implementation of HelpPrinter, and may be called directly if the |
| 173 |
ExtraInfo field is set on an App. |
| 174 |
|
| 175 |
In the default implementation, if the customFuncs argument contains a |
| 176 |
"wrapAt" key, which is a function which takes no arguments and returns an |
| 177 |
int, this int value will be used to produce a "wrap" function used by the |
| 178 |
default template to wrap long lines. |
| 179 |
|
| 180 |
|
| 181 |
FUNCTIONS |
| 182 |
|
| 183 |
func DefaultAppComplete(cCtx *Context) |
| 184 |
DefaultAppComplete prints the list of subcommands as the default app |
| 185 |
completion method |
| 186 |
|
| 187 |
func DefaultCompleteWithFlags(cmd *Command) func(cCtx *Context) |
| 188 |
func FlagNames(name string, aliases []string) []string |
| 189 |
func HandleAction(action interface{}, cCtx *Context) (err error) |
| 190 |
HandleAction attempts to figure out which Action signature was used. |
| 191 |
If it's an ActionFunc or a func with the legacy signature for Action, |
| 192 |
the func is run! |
| 193 |
|
| 194 |
func HandleExitCoder(err error) |
| 195 |
HandleExitCoder handles errors implementing ExitCoder by printing their |
| 196 |
message and calling OsExiter with the given exit code. |
| 197 |
|
| 198 |
If the given error instead implements MultiError, each error will be checked |
| 199 |
for the ExitCoder interface, and OsExiter will be called with the last exit |
| 200 |
code found, or exit code 1 if no ExitCoder is found. |
| 201 |
|
| 202 |
This function is the default error-handling behavior for an App. |
| 203 |
|
| 204 |
func ShowAppHelp(cCtx *Context) error |
| 205 |
ShowAppHelp is an action that displays the help. |
| 206 |
|
| 207 |
func ShowAppHelpAndExit(c *Context, exitCode int) |
| 208 |
ShowAppHelpAndExit - Prints the list of subcommands for the app and exits |
| 209 |
with exit code. |
| 210 |
|
| 211 |
func ShowCommandCompletions(ctx *Context, command string) |
| 212 |
ShowCommandCompletions prints the custom completions for a given command |
| 213 |
|
| 214 |
func ShowCommandHelp(ctx *Context, command string) error |
| 215 |
ShowCommandHelp prints help for the given command |
| 216 |
|
| 217 |
func ShowCommandHelpAndExit(c *Context, command string, code int) |
| 218 |
ShowCommandHelpAndExit - exits with code after showing help |
| 219 |
|
| 220 |
func ShowCompletions(cCtx *Context) |
| 221 |
ShowCompletions prints the lists of commands within a given context |
| 222 |
|
| 223 |
func ShowSubcommandHelp(cCtx *Context) error |
| 224 |
ShowSubcommandHelp prints help for the given subcommand |
| 225 |
|
| 226 |
func ShowSubcommandHelpAndExit(c *Context, exitCode int) |
| 227 |
ShowSubcommandHelpAndExit - Prints help for the given subcommand and exits |
| 228 |
with exit code. |
| 229 |
|
| 230 |
func ShowVersion(cCtx *Context) |
| 231 |
ShowVersion prints the version number of the App |
| 232 |
|
| 233 |
|
| 234 |
TYPES |
| 235 |
|
| 236 |
type ActionFunc func(*Context) error |
| 237 |
ActionFunc is the action to execute when no subcommands are specified |
| 238 |
|
| 239 |
type ActionableFlag interface { |
| 240 |
Flag |
| 241 |
RunAction(*Context) error |
| 242 |
} |
| 243 |
ActionableFlag is an interface that wraps Flag interface and RunAction |
| 244 |
operation. |
| 245 |
|
| 246 |
type AfterFunc func(*Context) error |
| 247 |
AfterFunc is an action to execute after any subcommands are run, but after |
| 248 |
the subcommand has finished it is run even if Action() panics |
| 249 |
|
| 250 |
type App struct { |
| 251 |
// The name of the program. Defaults to path.Base(os.Args[0]) |
| 252 |
Name string |
| 253 |
// Full name of command for help, defaults to Name |
| 254 |
HelpName string |
| 255 |
// Description of the program. |
| 256 |
Usage string |
| 257 |
// Text to override the USAGE section of help |
| 258 |
UsageText string |
| 259 |
// Whether this command supports arguments |
| 260 |
Args bool |
| 261 |
// Description of the program argument format. |
| 262 |
ArgsUsage string |
| 263 |
// Version of the program |
| 264 |
Version string |
| 265 |
// Description of the program |
| 266 |
Description string |
| 267 |
// DefaultCommand is the (optional) name of a command |
| 268 |
// to run if no command names are passed as CLI arguments. |
| 269 |
DefaultCommand string |
| 270 |
// List of commands to execute |
| 271 |
Commands []*Command |
| 272 |
// List of flags to parse |
| 273 |
Flags []Flag |
| 274 |
// Boolean to enable bash completion commands |
| 275 |
EnableBashCompletion bool |
| 276 |
// Boolean to hide built-in help command and help flag |
| 277 |
HideHelp bool |
| 278 |
// Boolean to hide built-in help command but keep help flag. |
| 279 |
// Ignored if HideHelp is true. |
| 280 |
HideHelpCommand bool |
| 281 |
// Boolean to hide built-in version flag and the VERSION section of help |
| 282 |
HideVersion bool |
| 283 |
|
| 284 |
// An action to execute when the shell completion flag is set |
| 285 |
BashComplete BashCompleteFunc |
| 286 |
// An action to execute before any subcommands are run, but after the context is ready |
| 287 |
// If a non-nil error is returned, no subcommands are run |
| 288 |
Before BeforeFunc |
| 289 |
// An action to execute after any subcommands are run, but after the subcommand has finished |
| 290 |
// It is run even if Action() panics |
| 291 |
After AfterFunc |
| 292 |
// The action to execute when no subcommands are specified |
| 293 |
Action ActionFunc |
| 294 |
// Execute this function if the proper command cannot be found |
| 295 |
CommandNotFound CommandNotFoundFunc |
| 296 |
// Execute this function if a usage error occurs |
| 297 |
OnUsageError OnUsageErrorFunc |
| 298 |
// Execute this function when an invalid flag is accessed from the context |
| 299 |
InvalidFlagAccessHandler InvalidFlagAccessFunc |
| 300 |
// Compilation date |
| 301 |
Compiled time.Time |
| 302 |
// List of all authors who contributed |
| 303 |
Authors []*Author |
| 304 |
// Copyright of the binary if any |
| 305 |
Copyright string |
| 306 |
// Reader reader to write input to (useful for tests) |
| 307 |
Reader io.Reader |
| 308 |
// Writer writer to write output to |
| 309 |
Writer io.Writer |
| 310 |
// ErrWriter writes error output |
| 311 |
ErrWriter io.Writer |
| 312 |
// ExitErrHandler processes any error encountered while running an App before |
| 313 |
// it is returned to the caller. If no function is provided, HandleExitCoder |
| 314 |
// is used as the default behavior. |
| 315 |
ExitErrHandler ExitErrHandlerFunc |
| 316 |
// Other custom info |
| 317 |
Metadata map[string]interface{} |
| 318 |
// Carries a function which returns app specific info. |
| 319 |
ExtraInfo func() map[string]string |
| 320 |
// CustomAppHelpTemplate the text template for app help topic. |
| 321 |
// cli.go uses text/template to render templates. You can |
| 322 |
// render custom help text by setting this variable. |
| 323 |
CustomAppHelpTemplate string |
| 324 |
// SliceFlagSeparator is used to customize the separator for SliceFlag, the default is "," |
| 325 |
SliceFlagSeparator string |
| 326 |
// DisableSliceFlagSeparator is used to disable SliceFlagSeparator, the default is false |
| 327 |
DisableSliceFlagSeparator bool |
| 328 |
// Boolean to enable short-option handling so user can combine several |
| 329 |
// single-character bool arguments into one |
| 330 |
// i.e. foobar -o -v -> foobar -ov |
| 331 |
UseShortOptionHandling bool |
| 332 |
// Enable suggestions for commands and flags |
| 333 |
Suggest bool |
| 334 |
// Allows global flags set by libraries which use flag.XXXVar(...) directly |
| 335 |
// to be parsed through this library |
| 336 |
AllowExtFlags bool |
| 337 |
// Treat all flags as normal arguments if true |
| 338 |
SkipFlagParsing bool |
| 339 |
|
| 340 |
// Has unexported fields. |
| 341 |
} |
| 342 |
App is the main structure of a cli application. It is recommended that an |
| 343 |
app be created with the cli.NewApp() function |
| 344 |
|
| 345 |
func NewApp() *App |
| 346 |
NewApp creates a new cli Application with some reasonable defaults for Name, |
| 347 |
Usage, Version and Action. |
| 348 |
|
| 349 |
func (a *App) Command(name string) *Command |
| 350 |
Command returns the named command on App. Returns nil if the command does |
| 351 |
not exist |
| 352 |
|
| 353 |
func (a *App) Run(arguments []string) (err error) |
| 354 |
Run is the entry point to the cli app. Parses the arguments slice and routes |
| 355 |
to the proper flag/args combination |
| 356 |
|
| 357 |
func (a *App) RunAndExitOnError() |
| 358 |
RunAndExitOnError calls .Run() and exits non-zero if an error was returned |
| 359 |
|
| 360 |
Deprecated: instead you should return an error that fulfills cli.ExitCoder |
| 361 |
to cli.App.Run. This will cause the application to exit with the given error |
| 362 |
code in the cli.ExitCoder |
| 363 |
|
| 364 |
func (a *App) RunAsSubcommand(ctx *Context) (err error) |
| 365 |
RunAsSubcommand is for legacy/compatibility purposes only. New code should |
| 366 |
only use App.RunContext. This function is slated to be removed in v3. |
| 367 |
|
| 368 |
func (a *App) RunContext(ctx context.Context, arguments []string) (err error) |
| 369 |
RunContext is like Run except it takes a Context that will be passed to |
| 370 |
its commands and sub-commands. Through this, you can propagate timeouts and |
| 371 |
cancellation requests |
| 372 |
|
| 373 |
func (a *App) Setup() |
| 374 |
Setup runs initialization code to ensure all data structures are ready |
| 375 |
for `Run` or inspection prior to `Run`. It is internally called by `Run`, |
| 376 |
but will return early if setup has already happened. |
| 377 |
|
| 378 |
func (a *App) ToFishCompletion() (string, error) |
| 379 |
ToFishCompletion creates a fish completion string for the `*App` The |
| 380 |
function errors if either parsing or writing of the string fails. |
| 381 |
|
| 382 |
func (a *App) ToMan() (string, error) |
| 383 |
ToMan creates a man page string for the `*App` The function errors if either |
| 384 |
parsing or writing of the string fails. |
| 385 |
|
| 386 |
func (a *App) ToManWithSection(sectionNumber int) (string, error) |
| 387 |
ToMan creates a man page string with section number for the `*App` The |
| 388 |
function errors if either parsing or writing of the string fails. |
| 389 |
|
| 390 |
func (a *App) ToMarkdown() (string, error) |
| 391 |
ToMarkdown creates a markdown string for the `*App` The function errors if |
| 392 |
either parsing or writing of the string fails. |
| 393 |
|
| 394 |
func (a *App) VisibleCategories() []CommandCategory |
| 395 |
VisibleCategories returns a slice of categories and commands that are |
| 396 |
Hidden=false |
| 397 |
|
| 398 |
func (a *App) VisibleCommands() []*Command |
| 399 |
VisibleCommands returns a slice of the Commands with Hidden=false |
| 400 |
|
| 401 |
func (a *App) VisibleFlagCategories() []VisibleFlagCategory |
| 402 |
VisibleFlagCategories returns a slice containing all the categories with the |
| 403 |
flags they contain |
| 404 |
|
| 405 |
func (a *App) VisibleFlags() []Flag |
| 406 |
VisibleFlags returns a slice of the Flags with Hidden=false |
| 407 |
|
| 408 |
type Args interface { |
| 409 |
// Get returns the nth argument, or else a blank string |
| 410 |
Get(n int) string |
| 411 |
// First returns the first argument, or else a blank string |
| 412 |
First() string |
| 413 |
// Tail returns the rest of the arguments (not the first one) |
| 414 |
// or else an empty string slice |
| 415 |
Tail() []string |
| 416 |
// Len returns the length of the wrapped slice |
| 417 |
Len() int |
| 418 |
// Present checks if there are any arguments present |
| 419 |
Present() bool |
| 420 |
// Slice returns a copy of the internal slice |
| 421 |
Slice() []string |
| 422 |
} |
| 423 |
|
| 424 |
type Author struct { |
| 425 |
Name string // The Authors name |
| 426 |
Email string // The Authors email |
| 427 |
} |
| 428 |
Author represents someone who has contributed to a cli project. |
| 429 |
|
| 430 |
func (a *Author) String() string |
| 431 |
String makes Author comply to the Stringer interface, to allow an easy print |
| 432 |
in the templating process |
| 433 |
|
| 434 |
type BashCompleteFunc func(*Context) |
| 435 |
BashCompleteFunc is an action to execute when the shell completion flag is |
| 436 |
set |
| 437 |
|
| 438 |
type BeforeFunc func(*Context) error |
| 439 |
BeforeFunc is an action to execute before any subcommands are run, but after |
| 440 |
the context is ready if a non-nil error is returned, no subcommands are run |
| 441 |
|
| 442 |
type BoolFlag struct { |
| 443 |
Name string |
| 444 |
|
| 445 |
Category string |
| 446 |
DefaultText string |
| 447 |
FilePath string |
| 448 |
Usage string |
| 449 |
|
| 450 |
Required bool |
| 451 |
Hidden bool |
| 452 |
HasBeenSet bool |
| 453 |
|
| 454 |
Value bool |
| 455 |
Destination *bool |
| 456 |
|
| 457 |
Aliases []string |
| 458 |
EnvVars []string |
| 459 |
|
| 460 |
Count *int |
| 461 |
|
| 462 |
DisableDefaultText bool |
| 463 |
|
| 464 |
Action func(*Context, bool) error |
| 465 |
// Has unexported fields. |
| 466 |
} |
| 467 |
BoolFlag is a flag with type bool |
| 468 |
|
| 469 |
func (f *BoolFlag) Apply(set *flag.FlagSet) error |
| 470 |
Apply populates the flag given the flag set and environment |
| 471 |
|
| 472 |
func (f *BoolFlag) Get(ctx *Context) bool |
| 473 |
Get returns the flag’s value in the given Context. |
| 474 |
|
| 475 |
func (f *BoolFlag) GetCategory() string |
| 476 |
GetCategory returns the category for the flag |
| 477 |
|
| 478 |
func (f *BoolFlag) GetDefaultText() string |
| 479 |
GetDefaultText returns the default text for this flag |
| 480 |
|
| 481 |
func (f *BoolFlag) GetEnvVars() []string |
| 482 |
GetEnvVars returns the env vars for this flag |
| 483 |
|
| 484 |
func (f *BoolFlag) GetUsage() string |
| 485 |
GetUsage returns the usage string for the flag |
| 486 |
|
| 487 |
func (f *BoolFlag) GetValue() string |
| 488 |
GetValue returns the flags value as string representation and an empty |
| 489 |
string if the flag takes no value at all. |
| 490 |
|
| 491 |
func (f *BoolFlag) IsRequired() bool |
| 492 |
IsRequired returns whether or not the flag is required |
| 493 |
|
| 494 |
func (f *BoolFlag) IsSet() bool |
| 495 |
IsSet returns whether or not the flag has been set through env or file |
| 496 |
|
| 497 |
func (f *BoolFlag) IsVisible() bool |
| 498 |
IsVisible returns true if the flag is not hidden, otherwise false |
| 499 |
|
| 500 |
func (f *BoolFlag) Names() []string |
| 501 |
Names returns the names of the flag |
| 502 |
|
| 503 |
func (f *BoolFlag) RunAction(c *Context) error |
| 504 |
RunAction executes flag action if set |
| 505 |
|
| 506 |
func (f *BoolFlag) String() string |
| 507 |
String returns a readable representation of this value (for usage defaults) |
| 508 |
|
| 509 |
func (f *BoolFlag) TakesValue() bool |
| 510 |
TakesValue returns true of the flag takes a value, otherwise false |
| 511 |
|
| 512 |
type CategorizableFlag interface { |
| 513 |
VisibleFlag |
| 514 |
|
| 515 |
GetCategory() string |
| 516 |
} |
| 517 |
CategorizableFlag is an interface that allows us to potentially use a flag |
| 518 |
in a categorized representation. |
| 519 |
|
| 520 |
type Command struct { |
| 521 |
// The name of the command |
| 522 |
Name string |
| 523 |
// A list of aliases for the command |
| 524 |
Aliases []string |
| 525 |
// A short description of the usage of this command |
| 526 |
Usage string |
| 527 |
// Custom text to show on USAGE section of help |
| 528 |
UsageText string |
| 529 |
// A longer explanation of how the command works |
| 530 |
Description string |
| 531 |
// Whether this command supports arguments |
| 532 |
Args bool |
| 533 |
// A short description of the arguments of this command |
| 534 |
ArgsUsage string |
| 535 |
// The category the command is part of |
| 536 |
Category string |
| 537 |
// The function to call when checking for bash command completions |
| 538 |
BashComplete BashCompleteFunc |
| 539 |
// An action to execute before any sub-subcommands are run, but after the context is ready |
| 540 |
// If a non-nil error is returned, no sub-subcommands are run |
| 541 |
Before BeforeFunc |
| 542 |
// An action to execute after any subcommands are run, but after the subcommand has finished |
| 543 |
// It is run even if Action() panics |
| 544 |
After AfterFunc |
| 545 |
// The function to call when this command is invoked |
| 546 |
Action ActionFunc |
| 547 |
// Execute this function if a usage error occurs. |
| 548 |
OnUsageError OnUsageErrorFunc |
| 549 |
// List of child commands |
| 550 |
Subcommands []*Command |
| 551 |
// List of flags to parse |
| 552 |
Flags []Flag |
| 553 |
|
| 554 |
// Treat all flags as normal arguments if true |
| 555 |
SkipFlagParsing bool |
| 556 |
// Boolean to hide built-in help command and help flag |
| 557 |
HideHelp bool |
| 558 |
// Boolean to hide built-in help command but keep help flag |
| 559 |
// Ignored if HideHelp is true. |
| 560 |
HideHelpCommand bool |
| 561 |
// Boolean to hide this command from help or completion |
| 562 |
Hidden bool |
| 563 |
// Boolean to enable short-option handling so user can combine several |
| 564 |
// single-character bool arguments into one |
| 565 |
// i.e. foobar -o -v -> foobar -ov |
| 566 |
UseShortOptionHandling bool |
| 567 |
|
| 568 |
// Full name of command for help, defaults to full command name, including parent commands. |
| 569 |
HelpName string |
| 570 |
|
| 571 |
// CustomHelpTemplate the text template for the command help topic. |
| 572 |
// cli.go uses text/template to render templates. You can |
| 573 |
// render custom help text by setting this variable. |
| 574 |
CustomHelpTemplate string |
| 575 |
|
| 576 |
// Has unexported fields. |
| 577 |
} |
| 578 |
Command is a subcommand for a cli.App. |
| 579 |
|
| 580 |
func (cmd *Command) Command(name string) *Command |
| 581 |
|
| 582 |
func (c *Command) FullName() string |
| 583 |
FullName returns the full name of the command. For subcommands this ensures |
| 584 |
that parent commands are part of the command path |
| 585 |
|
| 586 |
func (c *Command) HasName(name string) bool |
| 587 |
HasName returns true if Command.Name matches given name |
| 588 |
|
| 589 |
func (c *Command) Names() []string |
| 590 |
Names returns the names including short names and aliases. |
| 591 |
|
| 592 |
func (c *Command) Run(cCtx *Context, arguments ...string) (err error) |
| 593 |
|
| 594 |
func (c *Command) VisibleCategories() []CommandCategory |
| 595 |
VisibleCategories returns a slice of categories and commands that are |
| 596 |
Hidden=false |
| 597 |
|
| 598 |
func (c *Command) VisibleCommands() []*Command |
| 599 |
VisibleCommands returns a slice of the Commands with Hidden=false |
| 600 |
|
| 601 |
func (c *Command) VisibleFlagCategories() []VisibleFlagCategory |
| 602 |
VisibleFlagCategories returns a slice containing all the visible flag |
| 603 |
categories with the flags they contain |
| 604 |
|
| 605 |
func (c *Command) VisibleFlags() []Flag |
| 606 |
VisibleFlags returns a slice of the Flags with Hidden=false |
| 607 |
|
| 608 |
type CommandCategories interface { |
| 609 |
// AddCommand adds a command to a category, creating a new category if necessary. |
| 610 |
AddCommand(category string, command *Command) |
| 611 |
// Categories returns a slice of categories sorted by name |
| 612 |
Categories() []CommandCategory |
| 613 |
} |
| 614 |
CommandCategories interface allows for category manipulation |
| 615 |
|
| 616 |
type CommandCategory interface { |
| 617 |
// Name returns the category name string |
| 618 |
Name() string |
| 619 |
// VisibleCommands returns a slice of the Commands with Hidden=false |
| 620 |
VisibleCommands() []*Command |
| 621 |
} |
| 622 |
CommandCategory is a category containing commands. |
| 623 |
|
| 624 |
type CommandNotFoundFunc func(*Context, string) |
| 625 |
CommandNotFoundFunc is executed if the proper command cannot be found |
| 626 |
|
| 627 |
type Commands []*Command |
| 628 |
|
| 629 |
type CommandsByName []*Command |
| 630 |
|
| 631 |
func (c CommandsByName) Len() int |
| 632 |
|
| 633 |
func (c CommandsByName) Less(i, j int) bool |
| 634 |
|
| 635 |
func (c CommandsByName) Swap(i, j int) |
| 636 |
|
| 637 |
type Context struct { |
| 638 |
context.Context |
| 639 |
App *App |
| 640 |
Command *Command |
| 641 |
|
| 642 |
// Has unexported fields. |
| 643 |
} |
| 644 |
Context is a type that is passed through to each Handler action in a cli |
| 645 |
application. Context can be used to retrieve context-specific args and |
| 646 |
parsed command-line options. |
| 647 |
|
| 648 |
func NewContext(app *App, set *flag.FlagSet, parentCtx *Context) *Context |
| 649 |
NewContext creates a new context. For use in when invoking an App or Command |
| 650 |
action. |
| 651 |
|
| 652 |
func (cCtx *Context) Args() Args |
| 653 |
Args returns the command line arguments associated with the context. |
| 654 |
|
| 655 |
func (cCtx *Context) Bool(name string) bool |
| 656 |
Bool looks up the value of a local BoolFlag, returns false if not found |
| 657 |
|
| 658 |
func (cCtx *Context) Count(name string) int |
| 659 |
Count returns the num of occurrences of this flag |
| 660 |
|
| 661 |
func (cCtx *Context) Duration(name string) time.Duration |
| 662 |
Duration looks up the value of a local DurationFlag, returns 0 if not found |
| 663 |
|
| 664 |
func (cCtx *Context) FlagNames() []string |
| 665 |
FlagNames returns a slice of flag names used by the this context and all of |
| 666 |
its parent contexts. |
| 667 |
|
| 668 |
func (cCtx *Context) Float64(name string) float64 |
| 669 |
Float64 looks up the value of a local Float64Flag, returns 0 if not found |
| 670 |
|
| 671 |
func (cCtx *Context) Float64Slice(name string) []float64 |
| 672 |
Float64Slice looks up the value of a local Float64SliceFlag, returns nil if |
| 673 |
not found |
| 674 |
|
| 675 |
func (cCtx *Context) Generic(name string) interface{} |
| 676 |
Generic looks up the value of a local GenericFlag, returns nil if not found |
| 677 |
|
| 678 |
func (cCtx *Context) Int(name string) int |
| 679 |
Int looks up the value of a local IntFlag, returns 0 if not found |
| 680 |
|
| 681 |
func (cCtx *Context) Int64(name string) int64 |
| 682 |
Int64 looks up the value of a local Int64Flag, returns 0 if not found |
| 683 |
|
| 684 |
func (cCtx *Context) Int64Slice(name string) []int64 |
| 685 |
Int64Slice looks up the value of a local Int64SliceFlag, returns nil if not |
| 686 |
found |
| 687 |
|
| 688 |
func (cCtx *Context) IntSlice(name string) []int |
| 689 |
IntSlice looks up the value of a local IntSliceFlag, returns nil if not |
| 690 |
found |
| 691 |
|
| 692 |
func (cCtx *Context) IsSet(name string) bool |
| 693 |
IsSet determines if the flag was actually set |
| 694 |
|
| 695 |
func (cCtx *Context) Lineage() []*Context |
| 696 |
Lineage returns *this* context and all of its ancestor contexts in order |
| 697 |
from child to parent |
| 698 |
|
| 699 |
func (cCtx *Context) LocalFlagNames() []string |
| 700 |
LocalFlagNames returns a slice of flag names used in this context. |
| 701 |
|
| 702 |
func (cCtx *Context) NArg() int |
| 703 |
NArg returns the number of the command line arguments. |
| 704 |
|
| 705 |
func (cCtx *Context) NumFlags() int |
| 706 |
NumFlags returns the number of flags set |
| 707 |
|
| 708 |
func (cCtx *Context) Path(name string) string |
| 709 |
Path looks up the value of a local PathFlag, returns "" if not found |
| 710 |
|
| 711 |
func (cCtx *Context) Set(name, value string) error |
| 712 |
Set sets a context flag to a value. |
| 713 |
|
| 714 |
func (cCtx *Context) String(name string) string |
| 715 |
String looks up the value of a local StringFlag, returns "" if not found |
| 716 |
|
| 717 |
func (cCtx *Context) StringSlice(name string) []string |
| 718 |
StringSlice looks up the value of a local StringSliceFlag, returns nil if |
| 719 |
not found |
| 720 |
|
| 721 |
func (cCtx *Context) Timestamp(name string) *time.Time |
| 722 |
Timestamp gets the timestamp from a flag name |
| 723 |
|
| 724 |
func (cCtx *Context) Uint(name string) uint |
| 725 |
Uint looks up the value of a local UintFlag, returns 0 if not found |
| 726 |
|
| 727 |
func (cCtx *Context) Uint64(name string) uint64 |
| 728 |
Uint64 looks up the value of a local Uint64Flag, returns 0 if not found |
| 729 |
|
| 730 |
func (cCtx *Context) Uint64Slice(name string) []uint64 |
| 731 |
Uint64Slice looks up the value of a local Uint64SliceFlag, returns nil if |
| 732 |
not found |
| 733 |
|
| 734 |
func (cCtx *Context) UintSlice(name string) []uint |
| 735 |
UintSlice looks up the value of a local UintSliceFlag, returns nil if not |
| 736 |
found |
| 737 |
|
| 738 |
func (cCtx *Context) Value(name string) interface{} |
| 739 |
Value returns the value of the flag corresponding to `name` |
| 740 |
|
| 741 |
type Countable interface { |
| 742 |
Count() int |
| 743 |
} |
| 744 |
Countable is an interface to enable detection of flag values which support |
| 745 |
repetitive flags |
| 746 |
|
| 747 |
type DocGenerationFlag interface { |
| 748 |
Flag |
| 749 |
|
| 750 |
// TakesValue returns true if the flag takes a value, otherwise false |
| 751 |
TakesValue() bool |
| 752 |
|
| 753 |
// GetUsage returns the usage string for the flag |
| 754 |
GetUsage() string |
| 755 |
|
| 756 |
// GetValue returns the flags value as string representation and an empty |
| 757 |
// string if the flag takes no value at all. |
| 758 |
GetValue() string |
| 759 |
|
| 760 |
// GetDefaultText returns the default text for this flag |
| 761 |
GetDefaultText() string |
| 762 |
|
| 763 |
// GetEnvVars returns the env vars for this flag |
| 764 |
GetEnvVars() []string |
| 765 |
} |
| 766 |
DocGenerationFlag is an interface that allows documentation generation for |
| 767 |
the flag |
| 768 |
|
| 769 |
type DocGenerationSliceFlag interface { |
| 770 |
DocGenerationFlag |
| 771 |
|
| 772 |
// IsSliceFlag returns true for flags that can be given multiple times. |
| 773 |
IsSliceFlag() bool |
| 774 |
} |
| 775 |
DocGenerationSliceFlag extends DocGenerationFlag for slice-based flags. |
| 776 |
|
| 777 |
type DurationFlag struct { |
| 778 |
Name string |
| 779 |
|
| 780 |
Category string |
| 781 |
DefaultText string |
| 782 |
FilePath string |
| 783 |
Usage string |
| 784 |
|
| 785 |
Required bool |
| 786 |
Hidden bool |
| 787 |
HasBeenSet bool |
| 788 |
|
| 789 |
Value time.Duration |
| 790 |
Destination *time.Duration |
| 791 |
|
| 792 |
Aliases []string |
| 793 |
EnvVars []string |
| 794 |
|
| 795 |
Action func(*Context, time.Duration) error |
| 796 |
// Has unexported fields. |
| 797 |
} |
| 798 |
DurationFlag is a flag with type time.Duration |
| 799 |
|
| 800 |
func (f *DurationFlag) Apply(set *flag.FlagSet) error |
| 801 |
Apply populates the flag given the flag set and environment |
| 802 |
|
| 803 |
func (f *DurationFlag) Get(ctx *Context) time.Duration |
| 804 |
Get returns the flag’s value in the given Context. |
| 805 |
|
| 806 |
func (f *DurationFlag) GetCategory() string |
| 807 |
GetCategory returns the category for the flag |
| 808 |
|
| 809 |
func (f *DurationFlag) GetDefaultText() string |
| 810 |
GetDefaultText returns the default text for this flag |
| 811 |
|
| 812 |
func (f *DurationFlag) GetEnvVars() []string |
| 813 |
GetEnvVars returns the env vars for this flag |
| 814 |
|
| 815 |
func (f *DurationFlag) GetUsage() string |
| 816 |
GetUsage returns the usage string for the flag |
| 817 |
|
| 818 |
func (f *DurationFlag) GetValue() string |
| 819 |
GetValue returns the flags value as string representation and an empty |
| 820 |
string if the flag takes no value at all. |
| 821 |
|
| 822 |
func (f *DurationFlag) IsRequired() bool |
| 823 |
IsRequired returns whether or not the flag is required |
| 824 |
|
| 825 |
func (f *DurationFlag) IsSet() bool |
| 826 |
IsSet returns whether or not the flag has been set through env or file |
| 827 |
|
| 828 |
func (f *DurationFlag) IsVisible() bool |
| 829 |
IsVisible returns true if the flag is not hidden, otherwise false |
| 830 |
|
| 831 |
func (f *DurationFlag) Names() []string |
| 832 |
Names returns the names of the flag |
| 833 |
|
| 834 |
func (f *DurationFlag) RunAction(c *Context) error |
| 835 |
RunAction executes flag action if set |
| 836 |
|
| 837 |
func (f *DurationFlag) String() string |
| 838 |
String returns a readable representation of this value (for usage defaults) |
| 839 |
|
| 840 |
func (f *DurationFlag) TakesValue() bool |
| 841 |
TakesValue returns true of the flag takes a value, otherwise false |
| 842 |
|
| 843 |
type ErrorFormatter interface { |
| 844 |
Format(s fmt.State, verb rune) |
| 845 |
} |
| 846 |
ErrorFormatter is the interface that will suitably format the error output |
| 847 |
|
| 848 |
type ExitCoder interface { |
| 849 |
error |
| 850 |
ExitCode() int |
| 851 |
} |
| 852 |
ExitCoder is the interface checked by `App` and `Command` for a custom exit |
| 853 |
code |
| 854 |
|
| 855 |
func Exit(message interface{}, exitCode int) ExitCoder |
| 856 |
Exit wraps a message and exit code into an error, which by default is |
| 857 |
handled with a call to os.Exit during default error handling. |
| 858 |
|
| 859 |
This is the simplest way to trigger a non-zero exit code for an App |
| 860 |
without having to call os.Exit manually. During testing, this behavior |
| 861 |
can be avoided by overriding the ExitErrHandler function on an App or the |
| 862 |
package-global OsExiter function. |
| 863 |
|
| 864 |
func NewExitError(message interface{}, exitCode int) ExitCoder |
| 865 |
NewExitError calls Exit to create a new ExitCoder. |
| 866 |
|
| 867 |
Deprecated: This function is a duplicate of Exit and will eventually be |
| 868 |
removed. |
| 869 |
|
| 870 |
type ExitErrHandlerFunc func(cCtx *Context, err error) |
| 871 |
ExitErrHandlerFunc is executed if provided in order to handle exitError |
| 872 |
values returned by Actions and Before/After functions. |
| 873 |
|
| 874 |
type Flag interface { |
| 875 |
fmt.Stringer |
| 876 |
// Apply Flag settings to the given flag set |
| 877 |
Apply(*flag.FlagSet) error |
| 878 |
Names() []string |
| 879 |
IsSet() bool |
| 880 |
} |
| 881 |
Flag is a common interface related to parsing flags in cli. For more |
| 882 |
advanced flag parsing techniques, it is recommended that this interface be |
| 883 |
implemented. |
| 884 |
|
| 885 |
var BashCompletionFlag Flag = &BoolFlag{ |
| 886 |
Name: "generate-bash-completion", |
| 887 |
Hidden: true, |
| 888 |
} |
| 889 |
BashCompletionFlag enables bash-completion for all commands and subcommands |
| 890 |
|
| 891 |
var HelpFlag Flag = &BoolFlag{ |
| 892 |
Name: "help", |
| 893 |
Aliases: []string{"h"}, |
| 894 |
Usage: "show help", |
| 895 |
DisableDefaultText: true, |
| 896 |
} |
| 897 |
HelpFlag prints the help for all commands and subcommands. Set to nil to |
| 898 |
disable the flag. The subcommand will still be added unless HideHelp or |
| 899 |
HideHelpCommand is set to true. |
| 900 |
|
| 901 |
var VersionFlag Flag = &BoolFlag{ |
| 902 |
Name: "version", |
| 903 |
Aliases: []string{"v"}, |
| 904 |
Usage: "print the version", |
| 905 |
DisableDefaultText: true, |
| 906 |
} |
| 907 |
VersionFlag prints the version for the application |
| 908 |
|
| 909 |
type FlagCategories interface { |
| 910 |
// AddFlags adds a flag to a category, creating a new category if necessary. |
| 911 |
AddFlag(category string, fl Flag) |
| 912 |
// VisibleCategories returns a slice of visible flag categories sorted by name |
| 913 |
VisibleCategories() []VisibleFlagCategory |
| 914 |
} |
| 915 |
FlagCategories interface allows for category manipulation |
| 916 |
|
| 917 |
type FlagEnvHintFunc func(envVars []string, str string) string |
| 918 |
FlagEnvHintFunc is used by the default FlagStringFunc to annotate flag help |
| 919 |
with the environment variable details. |
| 920 |
|
| 921 |
var FlagEnvHinter FlagEnvHintFunc = withEnvHint |
| 922 |
FlagEnvHinter annotates flag help message with the environment variable |
| 923 |
details. This is used by the default FlagStringer. |
| 924 |
|
| 925 |
type FlagFileHintFunc func(filePath, str string) string |
| 926 |
FlagFileHintFunc is used by the default FlagStringFunc to annotate flag help |
| 927 |
with the file path details. |
| 928 |
|
| 929 |
var FlagFileHinter FlagFileHintFunc = withFileHint |
| 930 |
FlagFileHinter annotates flag help message with the environment variable |
| 931 |
details. This is used by the default FlagStringer. |
| 932 |
|
| 933 |
type FlagNamePrefixFunc func(fullName []string, placeholder string) string |
| 934 |
FlagNamePrefixFunc is used by the default FlagStringFunc to create prefix |
| 935 |
text for a flag's full name. |
| 936 |
|
| 937 |
var FlagNamePrefixer FlagNamePrefixFunc = prefixedNames |
| 938 |
FlagNamePrefixer converts a full flag name and its placeholder into the help |
| 939 |
message flag prefix. This is used by the default FlagStringer. |
| 940 |
|
| 941 |
type FlagStringFunc func(Flag) string |
| 942 |
FlagStringFunc is used by the help generation to display a flag, which is |
| 943 |
expected to be a single line. |
| 944 |
|
| 945 |
var FlagStringer FlagStringFunc = stringifyFlag |
| 946 |
FlagStringer converts a flag definition to a string. This is used by help to |
| 947 |
display a flag. |
| 948 |
|
| 949 |
type FlagsByName []Flag |
| 950 |
FlagsByName is a slice of Flag. |
| 951 |
|
| 952 |
func (f FlagsByName) Len() int |
| 953 |
|
| 954 |
func (f FlagsByName) Less(i, j int) bool |
| 955 |
|
| 956 |
func (f FlagsByName) Swap(i, j int) |
| 957 |
|
| 958 |
type Float64Flag struct { |
| 959 |
Name string |
| 960 |
|
| 961 |
Category string |
| 962 |
DefaultText string |
| 963 |
FilePath string |
| 964 |
Usage string |
| 965 |
|
| 966 |
Required bool |
| 967 |
Hidden bool |
| 968 |
HasBeenSet bool |
| 969 |
|
| 970 |
Value float64 |
| 971 |
Destination *float64 |
| 972 |
|
| 973 |
Aliases []string |
| 974 |
EnvVars []string |
| 975 |
|
| 976 |
Action func(*Context, float64) error |
| 977 |
// Has unexported fields. |
| 978 |
} |
| 979 |
Float64Flag is a flag with type float64 |
| 980 |
|
| 981 |
func (f *Float64Flag) Apply(set *flag.FlagSet) error |
| 982 |
Apply populates the flag given the flag set and environment |
| 983 |
|
| 984 |
func (f *Float64Flag) Get(ctx *Context) float64 |
| 985 |
Get returns the flag’s value in the given Context. |
| 986 |
|
| 987 |
func (f *Float64Flag) GetCategory() string |
| 988 |
GetCategory returns the category for the flag |
| 989 |
|
| 990 |
func (f *Float64Flag) GetDefaultText() string |
| 991 |
GetDefaultText returns the default text for this flag |
| 992 |
|
| 993 |
func (f *Float64Flag) GetEnvVars() []string |
| 994 |
GetEnvVars returns the env vars for this flag |
| 995 |
|
| 996 |
func (f *Float64Flag) GetUsage() string |
| 997 |
GetUsage returns the usage string for the flag |
| 998 |
|
| 999 |
func (f *Float64Flag) GetValue() string |
| 1000 |
GetValue returns the flags value as string representation and an empty |
| 1001 |
string if the flag takes no value at all. |
| 1002 |
|
| 1003 |
func (f *Float64Flag) IsRequired() bool |
| 1004 |
IsRequired returns whether or not the flag is required |
| 1005 |
|
| 1006 |
func (f *Float64Flag) IsSet() bool |
| 1007 |
IsSet returns whether or not the flag has been set through env or file |
| 1008 |
|
| 1009 |
func (f *Float64Flag) IsVisible() bool |
| 1010 |
IsVisible returns true if the flag is not hidden, otherwise false |
| 1011 |
|
| 1012 |
func (f *Float64Flag) Names() []string |
| 1013 |
Names returns the names of the flag |
| 1014 |
|
| 1015 |
func (f *Float64Flag) RunAction(c *Context) error |
| 1016 |
RunAction executes flag action if set |
| 1017 |
|
| 1018 |
func (f *Float64Flag) String() string |
| 1019 |
String returns a readable representation of this value (for usage defaults) |
| 1020 |
|
| 1021 |
func (f *Float64Flag) TakesValue() bool |
| 1022 |
TakesValue returns true of the flag takes a value, otherwise false |
| 1023 |
|
| 1024 |
type Float64Slice struct { |
| 1025 |
// Has unexported fields. |
| 1026 |
} |
| 1027 |
Float64Slice wraps []float64 to satisfy flag.Value |
| 1028 |
|
| 1029 |
func NewFloat64Slice(defaults ...float64) *Float64Slice |
| 1030 |
NewFloat64Slice makes a *Float64Slice with default values |
| 1031 |
|
| 1032 |
func (f *Float64Slice) Get() interface{} |
| 1033 |
Get returns the slice of float64s set by this flag |
| 1034 |
|
| 1035 |
func (f *Float64Slice) Serialize() string |
| 1036 |
Serialize allows Float64Slice to fulfill Serializer |
| 1037 |
|
| 1038 |
func (f *Float64Slice) Set(value string) error |
| 1039 |
Set parses the value into a float64 and appends it to the list of values |
| 1040 |
|
| 1041 |
func (f *Float64Slice) String() string |
| 1042 |
String returns a readable representation of this value (for usage defaults) |
| 1043 |
|
| 1044 |
func (f *Float64Slice) Value() []float64 |
| 1045 |
Value returns the slice of float64s set by this flag |
| 1046 |
|
| 1047 |
func (f *Float64Slice) WithSeparatorSpec(spec separatorSpec) |
| 1048 |
|
| 1049 |
type Float64SliceFlag struct { |
| 1050 |
Name string |
| 1051 |
|
| 1052 |
Category string |
| 1053 |
DefaultText string |
| 1054 |
FilePath string |
| 1055 |
Usage string |
| 1056 |
|
| 1057 |
Required bool |
| 1058 |
Hidden bool |
| 1059 |
HasBeenSet bool |
| 1060 |
|
| 1061 |
Value *Float64Slice |
| 1062 |
Destination *Float64Slice |
| 1063 |
|
| 1064 |
Aliases []string |
| 1065 |
EnvVars []string |
| 1066 |
|
| 1067 |
Action func(*Context, []float64) error |
| 1068 |
// Has unexported fields. |
| 1069 |
} |
| 1070 |
Float64SliceFlag is a flag with type *Float64Slice |
| 1071 |
|
| 1072 |
func (f *Float64SliceFlag) Apply(set *flag.FlagSet) error |
| 1073 |
Apply populates the flag given the flag set and environment |
| 1074 |
|
| 1075 |
func (f *Float64SliceFlag) Get(ctx *Context) []float64 |
| 1076 |
Get returns the flag’s value in the given Context. |
| 1077 |
|
| 1078 |
func (f *Float64SliceFlag) GetCategory() string |
| 1079 |
GetCategory returns the category for the flag |
| 1080 |
|
| 1081 |
func (f *Float64SliceFlag) GetDefaultText() string |
| 1082 |
GetDefaultText returns the default text for this flag |
| 1083 |
|
| 1084 |
func (f *Float64SliceFlag) GetDestination() []float64 |
| 1085 |
|
| 1086 |
func (f *Float64SliceFlag) GetEnvVars() []string |
| 1087 |
GetEnvVars returns the env vars for this flag |
| 1088 |
|
| 1089 |
func (f *Float64SliceFlag) GetUsage() string |
| 1090 |
GetUsage returns the usage string for the flag |
| 1091 |
|
| 1092 |
func (f *Float64SliceFlag) GetValue() string |
| 1093 |
GetValue returns the flags value as string representation and an empty |
| 1094 |
string if the flag takes no value at all. |
| 1095 |
|
| 1096 |
func (f *Float64SliceFlag) IsRequired() bool |
| 1097 |
IsRequired returns whether or not the flag is required |
| 1098 |
|
| 1099 |
func (f *Float64SliceFlag) IsSet() bool |
| 1100 |
IsSet returns whether or not the flag has been set through env or file |
| 1101 |
|
| 1102 |
func (f *Float64SliceFlag) IsSliceFlag() bool |
| 1103 |
IsSliceFlag implements DocGenerationSliceFlag. |
| 1104 |
|
| 1105 |
func (f *Float64SliceFlag) IsVisible() bool |
| 1106 |
IsVisible returns true if the flag is not hidden, otherwise false |
| 1107 |
|
| 1108 |
func (f *Float64SliceFlag) Names() []string |
| 1109 |
Names returns the names of the flag |
| 1110 |
|
| 1111 |
func (f *Float64SliceFlag) RunAction(c *Context) error |
| 1112 |
RunAction executes flag action if set |
| 1113 |
|
| 1114 |
func (f *Float64SliceFlag) SetDestination(slice []float64) |
| 1115 |
|
| 1116 |
func (f *Float64SliceFlag) SetValue(slice []float64) |
| 1117 |
|
| 1118 |
func (f *Float64SliceFlag) String() string |
| 1119 |
String returns a readable representation of this value (for usage defaults) |
| 1120 |
|
| 1121 |
func (f *Float64SliceFlag) TakesValue() bool |
| 1122 |
TakesValue returns true if the flag takes a value, otherwise false |
| 1123 |
|
| 1124 |
func (f *Float64SliceFlag) WithSeparatorSpec(spec separatorSpec) |
| 1125 |
|
| 1126 |
type Generic interface { |
| 1127 |
Set(value string) error |
| 1128 |
String() string |
| 1129 |
} |
| 1130 |
Generic is a generic parseable type identified by a specific flag |
| 1131 |
|
| 1132 |
type GenericFlag struct { |
| 1133 |
Name string |
| 1134 |
|
| 1135 |
Category string |
| 1136 |
DefaultText string |
| 1137 |
FilePath string |
| 1138 |
Usage string |
| 1139 |
|
| 1140 |
Required bool |
| 1141 |
Hidden bool |
| 1142 |
HasBeenSet bool |
| 1143 |
|
| 1144 |
Value Generic |
| 1145 |
Destination Generic |
| 1146 |
|
| 1147 |
Aliases []string |
| 1148 |
EnvVars []string |
| 1149 |
|
| 1150 |
TakesFile bool |
| 1151 |
|
| 1152 |
Action func(*Context, interface{}) error |
| 1153 |
// Has unexported fields. |
| 1154 |
} |
| 1155 |
GenericFlag is a flag with type Generic |
| 1156 |
|
| 1157 |
func (f *GenericFlag) Apply(set *flag.FlagSet) error |
| 1158 |
Apply takes the flagset and calls Set on the generic flag with the value |
| 1159 |
provided by the user for parsing by the flag |
| 1160 |
|
| 1161 |
func (f *GenericFlag) Get(ctx *Context) interface{} |
| 1162 |
Get returns the flag’s value in the given Context. |
| 1163 |
|
| 1164 |
func (f *GenericFlag) GetCategory() string |
| 1165 |
GetCategory returns the category for the flag |
| 1166 |
|
| 1167 |
func (f *GenericFlag) GetDefaultText() string |
| 1168 |
GetDefaultText returns the default text for this flag |
| 1169 |
|
| 1170 |
func (f *GenericFlag) GetEnvVars() []string |
| 1171 |
GetEnvVars returns the env vars for this flag |
| 1172 |
|
| 1173 |
func (f *GenericFlag) GetUsage() string |
| 1174 |
GetUsage returns the usage string for the flag |
| 1175 |
|
| 1176 |
func (f *GenericFlag) GetValue() string |
| 1177 |
GetValue returns the flags value as string representation and an empty |
| 1178 |
string if the flag takes no value at all. |
| 1179 |
|
| 1180 |
func (f *GenericFlag) IsRequired() bool |
| 1181 |
IsRequired returns whether or not the flag is required |
| 1182 |
|
| 1183 |
func (f *GenericFlag) IsSet() bool |
| 1184 |
IsSet returns whether or not the flag has been set through env or file |
| 1185 |
|
| 1186 |
func (f *GenericFlag) IsVisible() bool |
| 1187 |
IsVisible returns true if the flag is not hidden, otherwise false |
| 1188 |
|
| 1189 |
func (f *GenericFlag) Names() []string |
| 1190 |
Names returns the names of the flag |
| 1191 |
|
| 1192 |
func (f *GenericFlag) RunAction(c *Context) error |
| 1193 |
RunAction executes flag action if set |
| 1194 |
|
| 1195 |
func (f *GenericFlag) String() string |
| 1196 |
String returns a readable representation of this value (for usage defaults) |
| 1197 |
|
| 1198 |
func (f *GenericFlag) TakesValue() bool |
| 1199 |
TakesValue returns true of the flag takes a value, otherwise false |
| 1200 |
|
| 1201 |
type Int64Flag struct { |
| 1202 |
Name string |
| 1203 |
|
| 1204 |
Category string |
| 1205 |
DefaultText string |
| 1206 |
FilePath string |
| 1207 |
Usage string |
| 1208 |
|
| 1209 |
Required bool |
| 1210 |
Hidden bool |
| 1211 |
HasBeenSet bool |
| 1212 |
|
| 1213 |
Value int64 |
| 1214 |
Destination *int64 |
| 1215 |
|
| 1216 |
Aliases []string |
| 1217 |
EnvVars []string |
| 1218 |
|
| 1219 |
Base int |
| 1220 |
|
| 1221 |
Action func(*Context, int64) error |
| 1222 |
// Has unexported fields. |
| 1223 |
} |
| 1224 |
Int64Flag is a flag with type int64 |
| 1225 |
|
| 1226 |
func (f *Int64Flag) Apply(set *flag.FlagSet) error |
| 1227 |
Apply populates the flag given the flag set and environment |
| 1228 |
|
| 1229 |
func (f *Int64Flag) Get(ctx *Context) int64 |
| 1230 |
Get returns the flag’s value in the given Context. |
| 1231 |
|
| 1232 |
func (f *Int64Flag) GetCategory() string |
| 1233 |
GetCategory returns the category for the flag |
| 1234 |
|
| 1235 |
func (f *Int64Flag) GetDefaultText() string |
| 1236 |
GetDefaultText returns the default text for this flag |
| 1237 |
|
| 1238 |
func (f *Int64Flag) GetEnvVars() []string |
| 1239 |
GetEnvVars returns the env vars for this flag |
| 1240 |
|
| 1241 |
func (f *Int64Flag) GetUsage() string |
| 1242 |
GetUsage returns the usage string for the flag |
| 1243 |
|
| 1244 |
func (f *Int64Flag) GetValue() string |
| 1245 |
GetValue returns the flags value as string representation and an empty |
| 1246 |
string if the flag takes no value at all. |
| 1247 |
|
| 1248 |
func (f *Int64Flag) IsRequired() bool |
| 1249 |
IsRequired returns whether or not the flag is required |
| 1250 |
|
| 1251 |
func (f *Int64Flag) IsSet() bool |
| 1252 |
IsSet returns whether or not the flag has been set through env or file |
| 1253 |
|
| 1254 |
func (f *Int64Flag) IsVisible() bool |
| 1255 |
IsVisible returns true if the flag is not hidden, otherwise false |
| 1256 |
|
| 1257 |
func (f *Int64Flag) Names() []string |
| 1258 |
Names returns the names of the flag |
| 1259 |
|
| 1260 |
func (f *Int64Flag) RunAction(c *Context) error |
| 1261 |
RunAction executes flag action if set |
| 1262 |
|
| 1263 |
func (f *Int64Flag) String() string |
| 1264 |
String returns a readable representation of this value (for usage defaults) |
| 1265 |
|
| 1266 |
func (f *Int64Flag) TakesValue() bool |
| 1267 |
TakesValue returns true of the flag takes a value, otherwise false |
| 1268 |
|
| 1269 |
type Int64Slice struct { |
| 1270 |
// Has unexported fields. |
| 1271 |
} |
| 1272 |
Int64Slice wraps []int64 to satisfy flag.Value |
| 1273 |
|
| 1274 |
func NewInt64Slice(defaults ...int64) *Int64Slice |
| 1275 |
NewInt64Slice makes an *Int64Slice with default values |
| 1276 |
|
| 1277 |
func (i *Int64Slice) Get() interface{} |
| 1278 |
Get returns the slice of ints set by this flag |
| 1279 |
|
| 1280 |
func (i *Int64Slice) Serialize() string |
| 1281 |
Serialize allows Int64Slice to fulfill Serializer |
| 1282 |
|
| 1283 |
func (i *Int64Slice) Set(value string) error |
| 1284 |
Set parses the value into an integer and appends it to the list of values |
| 1285 |
|
| 1286 |
func (i *Int64Slice) String() string |
| 1287 |
String returns a readable representation of this value (for usage defaults) |
| 1288 |
|
| 1289 |
func (i *Int64Slice) Value() []int64 |
| 1290 |
Value returns the slice of ints set by this flag |
| 1291 |
|
| 1292 |
func (i *Int64Slice) WithSeparatorSpec(spec separatorSpec) |
| 1293 |
|
| 1294 |
type Int64SliceFlag struct { |
| 1295 |
Name string |
| 1296 |
|
| 1297 |
Category string |
| 1298 |
DefaultText string |
| 1299 |
FilePath string |
| 1300 |
Usage string |
| 1301 |
|
| 1302 |
Required bool |
| 1303 |
Hidden bool |
| 1304 |
HasBeenSet bool |
| 1305 |
|
| 1306 |
Value *Int64Slice |
| 1307 |
Destination *Int64Slice |
| 1308 |
|
| 1309 |
Aliases []string |
| 1310 |
EnvVars []string |
| 1311 |
|
| 1312 |
Action func(*Context, []int64) error |
| 1313 |
// Has unexported fields. |
| 1314 |
} |
| 1315 |
Int64SliceFlag is a flag with type *Int64Slice |
| 1316 |
|
| 1317 |
func (f *Int64SliceFlag) Apply(set *flag.FlagSet) error |
| 1318 |
Apply populates the flag given the flag set and environment |
| 1319 |
|
| 1320 |
func (f *Int64SliceFlag) Get(ctx *Context) []int64 |
| 1321 |
Get returns the flag’s value in the given Context. |
| 1322 |
|
| 1323 |
func (f *Int64SliceFlag) GetCategory() string |
| 1324 |
GetCategory returns the category for the flag |
| 1325 |
|
| 1326 |
func (f *Int64SliceFlag) GetDefaultText() string |
| 1327 |
GetDefaultText returns the default text for this flag |
| 1328 |
|
| 1329 |
func (f *Int64SliceFlag) GetDestination() []int64 |
| 1330 |
|
| 1331 |
func (f *Int64SliceFlag) GetEnvVars() []string |
| 1332 |
GetEnvVars returns the env vars for this flag |
| 1333 |
|
| 1334 |
func (f *Int64SliceFlag) GetUsage() string |
| 1335 |
GetUsage returns the usage string for the flag |
| 1336 |
|
| 1337 |
func (f *Int64SliceFlag) GetValue() string |
| 1338 |
GetValue returns the flags value as string representation and an empty |
| 1339 |
string if the flag takes no value at all. |
| 1340 |
|
| 1341 |
func (f *Int64SliceFlag) IsRequired() bool |
| 1342 |
IsRequired returns whether or not the flag is required |
| 1343 |
|
| 1344 |
func (f *Int64SliceFlag) IsSet() bool |
| 1345 |
IsSet returns whether or not the flag has been set through env or file |
| 1346 |
|
| 1347 |
func (f *Int64SliceFlag) IsSliceFlag() bool |
| 1348 |
IsSliceFlag implements DocGenerationSliceFlag. |
| 1349 |
|
| 1350 |
func (f *Int64SliceFlag) IsVisible() bool |
| 1351 |
IsVisible returns true if the flag is not hidden, otherwise false |
| 1352 |
|
| 1353 |
func (f *Int64SliceFlag) Names() []string |
| 1354 |
Names returns the names of the flag |
| 1355 |
|
| 1356 |
func (f *Int64SliceFlag) RunAction(c *Context) error |
| 1357 |
RunAction executes flag action if set |
| 1358 |
|
| 1359 |
func (f *Int64SliceFlag) SetDestination(slice []int64) |
| 1360 |
|
| 1361 |
func (f *Int64SliceFlag) SetValue(slice []int64) |
| 1362 |
|
| 1363 |
func (f *Int64SliceFlag) String() string |
| 1364 |
String returns a readable representation of this value (for usage defaults) |
| 1365 |
|
| 1366 |
func (f *Int64SliceFlag) TakesValue() bool |
| 1367 |
TakesValue returns true of the flag takes a value, otherwise false |
| 1368 |
|
| 1369 |
func (f *Int64SliceFlag) WithSeparatorSpec(spec separatorSpec) |
| 1370 |
|
| 1371 |
type IntFlag struct { |
| 1372 |
Name string |
| 1373 |
|
| 1374 |
Category string |
| 1375 |
DefaultText string |
| 1376 |
FilePath string |
| 1377 |
Usage string |
| 1378 |
|
| 1379 |
Required bool |
| 1380 |
Hidden bool |
| 1381 |
HasBeenSet bool |
| 1382 |
|
| 1383 |
Value int |
| 1384 |
Destination *int |
| 1385 |
|
| 1386 |
Aliases []string |
| 1387 |
EnvVars []string |
| 1388 |
|
| 1389 |
Base int |
| 1390 |
|
| 1391 |
Action func(*Context, int) error |
| 1392 |
// Has unexported fields. |
| 1393 |
} |
| 1394 |
IntFlag is a flag with type int |
| 1395 |
|
| 1396 |
func (f *IntFlag) Apply(set *flag.FlagSet) error |
| 1397 |
Apply populates the flag given the flag set and environment |
| 1398 |
|
| 1399 |
func (f *IntFlag) Get(ctx *Context) int |
| 1400 |
Get returns the flag’s value in the given Context. |
| 1401 |
|
| 1402 |
func (f *IntFlag) GetCategory() string |
| 1403 |
GetCategory returns the category for the flag |
| 1404 |
|
| 1405 |
func (f *IntFlag) GetDefaultText() string |
| 1406 |
GetDefaultText returns the default text for this flag |
| 1407 |
|
| 1408 |
func (f *IntFlag) GetEnvVars() []string |
| 1409 |
GetEnvVars returns the env vars for this flag |
| 1410 |
|
| 1411 |
func (f *IntFlag) GetUsage() string |
| 1412 |
GetUsage returns the usage string for the flag |
| 1413 |
|
| 1414 |
func (f *IntFlag) GetValue() string |
| 1415 |
GetValue returns the flags value as string representation and an empty |
| 1416 |
string if the flag takes no value at all. |
| 1417 |
|
| 1418 |
func (f *IntFlag) IsRequired() bool |
| 1419 |
IsRequired returns whether or not the flag is required |
| 1420 |
|
| 1421 |
func (f *IntFlag) IsSet() bool |
| 1422 |
IsSet returns whether or not the flag has been set through env or file |
| 1423 |
|
| 1424 |
func (f *IntFlag) IsVisible() bool |
| 1425 |
IsVisible returns true if the flag is not hidden, otherwise false |
| 1426 |
|
| 1427 |
func (f *IntFlag) Names() []string |
| 1428 |
Names returns the names of the flag |
| 1429 |
|
| 1430 |
func (f *IntFlag) RunAction(c *Context) error |
| 1431 |
RunAction executes flag action if set |
| 1432 |
|
| 1433 |
func (f *IntFlag) String() string |
| 1434 |
String returns a readable representation of this value (for usage defaults) |
| 1435 |
|
| 1436 |
func (f *IntFlag) TakesValue() bool |
| 1437 |
TakesValue returns true of the flag takes a value, otherwise false |
| 1438 |
|
| 1439 |
type IntSlice struct { |
| 1440 |
// Has unexported fields. |
| 1441 |
} |
| 1442 |
IntSlice wraps []int to satisfy flag.Value |
| 1443 |
|
| 1444 |
func NewIntSlice(defaults ...int) *IntSlice |
| 1445 |
NewIntSlice makes an *IntSlice with default values |
| 1446 |
|
| 1447 |
func (i *IntSlice) Get() interface{} |
| 1448 |
Get returns the slice of ints set by this flag |
| 1449 |
|
| 1450 |
func (i *IntSlice) Serialize() string |
| 1451 |
Serialize allows IntSlice to fulfill Serializer |
| 1452 |
|
| 1453 |
func (i *IntSlice) Set(value string) error |
| 1454 |
Set parses the value into an integer and appends it to the list of values |
| 1455 |
|
| 1456 |
func (i *IntSlice) SetInt(value int) |
| 1457 |
TODO: Consistently have specific Set function for Int64 and Float64 ? SetInt |
| 1458 |
directly adds an integer to the list of values |
| 1459 |
|
| 1460 |
func (i *IntSlice) String() string |
| 1461 |
String returns a readable representation of this value (for usage defaults) |
| 1462 |
|
| 1463 |
func (i *IntSlice) Value() []int |
| 1464 |
Value returns the slice of ints set by this flag |
| 1465 |
|
| 1466 |
func (i *IntSlice) WithSeparatorSpec(spec separatorSpec) |
| 1467 |
|
| 1468 |
type IntSliceFlag struct { |
| 1469 |
Name string |
| 1470 |
|
| 1471 |
Category string |
| 1472 |
DefaultText string |
| 1473 |
FilePath string |
| 1474 |
Usage string |
| 1475 |
|
| 1476 |
Required bool |
| 1477 |
Hidden bool |
| 1478 |
HasBeenSet bool |
| 1479 |
|
| 1480 |
Value *IntSlice |
| 1481 |
Destination *IntSlice |
| 1482 |
|
| 1483 |
Aliases []string |
| 1484 |
EnvVars []string |
| 1485 |
|
| 1486 |
Action func(*Context, []int) error |
| 1487 |
// Has unexported fields. |
| 1488 |
} |
| 1489 |
IntSliceFlag is a flag with type *IntSlice |
| 1490 |
|
| 1491 |
func (f *IntSliceFlag) Apply(set *flag.FlagSet) error |
| 1492 |
Apply populates the flag given the flag set and environment |
| 1493 |
|
| 1494 |
func (f *IntSliceFlag) Get(ctx *Context) []int |
| 1495 |
Get returns the flag’s value in the given Context. |
| 1496 |
|
| 1497 |
func (f *IntSliceFlag) GetCategory() string |
| 1498 |
GetCategory returns the category for the flag |
| 1499 |
|
| 1500 |
func (f *IntSliceFlag) GetDefaultText() string |
| 1501 |
GetDefaultText returns the default text for this flag |
| 1502 |
|
| 1503 |
func (f *IntSliceFlag) GetDestination() []int |
| 1504 |
|
| 1505 |
func (f *IntSliceFlag) GetEnvVars() []string |
| 1506 |
GetEnvVars returns the env vars for this flag |
| 1507 |
|
| 1508 |
func (f *IntSliceFlag) GetUsage() string |
| 1509 |
GetUsage returns the usage string for the flag |
| 1510 |
|
| 1511 |
func (f *IntSliceFlag) GetValue() string |
| 1512 |
GetValue returns the flags value as string representation and an empty |
| 1513 |
string if the flag takes no value at all. |
| 1514 |
|
| 1515 |
func (f *IntSliceFlag) IsRequired() bool |
| 1516 |
IsRequired returns whether or not the flag is required |
| 1517 |
|
| 1518 |
func (f *IntSliceFlag) IsSet() bool |
| 1519 |
IsSet returns whether or not the flag has been set through env or file |
| 1520 |
|
| 1521 |
func (f *IntSliceFlag) IsSliceFlag() bool |
| 1522 |
IsSliceFlag implements DocGenerationSliceFlag. |
| 1523 |
|
| 1524 |
func (f *IntSliceFlag) IsVisible() bool |
| 1525 |
IsVisible returns true if the flag is not hidden, otherwise false |
| 1526 |
|
| 1527 |
func (f *IntSliceFlag) Names() []string |
| 1528 |
Names returns the names of the flag |
| 1529 |
|
| 1530 |
func (f *IntSliceFlag) RunAction(c *Context) error |
| 1531 |
RunAction executes flag action if set |
| 1532 |
|
| 1533 |
func (f *IntSliceFlag) SetDestination(slice []int) |
| 1534 |
|
| 1535 |
func (f *IntSliceFlag) SetValue(slice []int) |
| 1536 |
|
| 1537 |
func (f *IntSliceFlag) String() string |
| 1538 |
String returns a readable representation of this value (for usage defaults) |
| 1539 |
|
| 1540 |
func (f *IntSliceFlag) TakesValue() bool |
| 1541 |
TakesValue returns true of the flag takes a value, otherwise false |
| 1542 |
|
| 1543 |
func (f *IntSliceFlag) WithSeparatorSpec(spec separatorSpec) |
| 1544 |
|
| 1545 |
type InvalidFlagAccessFunc func(*Context, string) |
| 1546 |
InvalidFlagAccessFunc is executed when an invalid flag is accessed from the |
| 1547 |
context. |
| 1548 |
|
| 1549 |
type MultiError interface { |
| 1550 |
error |
| 1551 |
Errors() []error |
| 1552 |
} |
| 1553 |
MultiError is an error that wraps multiple errors. |
| 1554 |
|
| 1555 |
type MultiFloat64Flag = SliceFlag[*Float64SliceFlag, []float64, float64] |
| 1556 |
MultiFloat64Flag extends Float64SliceFlag with support for using slices |
| 1557 |
directly, as Value and/or Destination. See also SliceFlag. |
| 1558 |
|
| 1559 |
type MultiInt64Flag = SliceFlag[*Int64SliceFlag, []int64, int64] |
| 1560 |
MultiInt64Flag extends Int64SliceFlag with support for using slices |
| 1561 |
directly, as Value and/or Destination. See also SliceFlag. |
| 1562 |
|
| 1563 |
type MultiIntFlag = SliceFlag[*IntSliceFlag, []int, int] |
| 1564 |
MultiIntFlag extends IntSliceFlag with support for using slices directly, |
| 1565 |
as Value and/or Destination. See also SliceFlag. |
| 1566 |
|
| 1567 |
type MultiStringFlag = SliceFlag[*StringSliceFlag, []string, string] |
| 1568 |
MultiStringFlag extends StringSliceFlag with support for using slices |
| 1569 |
directly, as Value and/or Destination. See also SliceFlag. |
| 1570 |
|
| 1571 |
type OnUsageErrorFunc func(cCtx *Context, err error, isSubcommand bool) error |
| 1572 |
OnUsageErrorFunc is executed if a usage error occurs. This is useful for |
| 1573 |
displaying customized usage error messages. This function is able to replace |
| 1574 |
the original error messages. If this function is not set, the "Incorrect |
| 1575 |
usage" is displayed and the execution is interrupted. |
| 1576 |
|
| 1577 |
type Path = string |
| 1578 |
|
| 1579 |
type PathFlag struct { |
| 1580 |
Name string |
| 1581 |
|
| 1582 |
Category string |
| 1583 |
DefaultText string |
| 1584 |
FilePath string |
| 1585 |
Usage string |
| 1586 |
|
| 1587 |
Required bool |
| 1588 |
Hidden bool |
| 1589 |
HasBeenSet bool |
| 1590 |
|
| 1591 |
Value Path |
| 1592 |
Destination *Path |
| 1593 |
|
| 1594 |
Aliases []string |
| 1595 |
EnvVars []string |
| 1596 |
|
| 1597 |
TakesFile bool |
| 1598 |
|
| 1599 |
Action func(*Context, Path) error |
| 1600 |
// Has unexported fields. |
| 1601 |
} |
| 1602 |
PathFlag is a flag with type Path |
| 1603 |
|
| 1604 |
func (f *PathFlag) Apply(set *flag.FlagSet) error |
| 1605 |
Apply populates the flag given the flag set and environment |
| 1606 |
|
| 1607 |
func (f *PathFlag) Get(ctx *Context) string |
| 1608 |
Get returns the flag’s value in the given Context. |
| 1609 |
|
| 1610 |
func (f *PathFlag) GetCategory() string |
| 1611 |
GetCategory returns the category for the flag |
| 1612 |
|
| 1613 |
func (f *PathFlag) GetDefaultText() string |
| 1614 |
GetDefaultText returns the default text for this flag |
| 1615 |
|
| 1616 |
func (f *PathFlag) GetEnvVars() []string |
| 1617 |
GetEnvVars returns the env vars for this flag |
| 1618 |
|
| 1619 |
func (f *PathFlag) GetUsage() string |
| 1620 |
GetUsage returns the usage string for the flag |
| 1621 |
|
| 1622 |
func (f *PathFlag) GetValue() string |
| 1623 |
GetValue returns the flags value as string representation and an empty |
| 1624 |
string if the flag takes no value at all. |
| 1625 |
|
| 1626 |
func (f *PathFlag) IsRequired() bool |
| 1627 |
IsRequired returns whether or not the flag is required |
| 1628 |
|
| 1629 |
func (f *PathFlag) IsSet() bool |
| 1630 |
IsSet returns whether or not the flag has been set through env or file |
| 1631 |
|
| 1632 |
func (f *PathFlag) IsVisible() bool |
| 1633 |
IsVisible returns true if the flag is not hidden, otherwise false |
| 1634 |
|
| 1635 |
func (f *PathFlag) Names() []string |
| 1636 |
Names returns the names of the flag |
| 1637 |
|
| 1638 |
func (f *PathFlag) RunAction(c *Context) error |
| 1639 |
RunAction executes flag action if set |
| 1640 |
|
| 1641 |
func (f *PathFlag) String() string |
| 1642 |
String returns a readable representation of this value (for usage defaults) |
| 1643 |
|
| 1644 |
func (f *PathFlag) TakesValue() bool |
| 1645 |
TakesValue returns true of the flag takes a value, otherwise false |
| 1646 |
|
| 1647 |
type RequiredFlag interface { |
| 1648 |
Flag |
| 1649 |
|
| 1650 |
IsRequired() bool |
| 1651 |
} |
| 1652 |
RequiredFlag is an interface that allows us to mark flags as required |
| 1653 |
it allows flags required flags to be backwards compatible with the Flag |
| 1654 |
interface |
| 1655 |
|
| 1656 |
type Serializer interface { |
| 1657 |
Serialize() string |
| 1658 |
} |
| 1659 |
Serializer is used to circumvent the limitations of flag.FlagSet.Set |
| 1660 |
|
| 1661 |
type SliceFlag[T SliceFlagTarget[E], S ~[]E, E any] struct { |
| 1662 |
Target T |
| 1663 |
Value S |
| 1664 |
Destination *S |
| 1665 |
} |
| 1666 |
SliceFlag extends implementations like StringSliceFlag and IntSliceFlag |
| 1667 |
with support for using slices directly, as Value and/or Destination. |
| 1668 |
See also SliceFlagTarget, MultiStringFlag, MultiFloat64Flag, MultiInt64Flag, |
| 1669 |
MultiIntFlag. |
| 1670 |
|
| 1671 |
func (x *SliceFlag[T, S, E]) Apply(set *flag.FlagSet) error |
| 1672 |
|
| 1673 |
func (x *SliceFlag[T, S, E]) GetCategory() string |
| 1674 |
|
| 1675 |
func (x *SliceFlag[T, S, E]) GetDefaultText() string |
| 1676 |
|
| 1677 |
func (x *SliceFlag[T, S, E]) GetDestination() S |
| 1678 |
|
| 1679 |
func (x *SliceFlag[T, S, E]) GetEnvVars() []string |
| 1680 |
|
| 1681 |
func (x *SliceFlag[T, S, E]) GetUsage() string |
| 1682 |
|
| 1683 |
func (x *SliceFlag[T, S, E]) GetValue() string |
| 1684 |
|
| 1685 |
func (x *SliceFlag[T, S, E]) IsRequired() bool |
| 1686 |
|
| 1687 |
func (x *SliceFlag[T, S, E]) IsSet() bool |
| 1688 |
|
| 1689 |
func (x *SliceFlag[T, S, E]) IsVisible() bool |
| 1690 |
|
| 1691 |
func (x *SliceFlag[T, S, E]) Names() []string |
| 1692 |
|
| 1693 |
func (x *SliceFlag[T, S, E]) SetDestination(slice S) |
| 1694 |
|
| 1695 |
func (x *SliceFlag[T, S, E]) SetValue(slice S) |
| 1696 |
|
| 1697 |
func (x *SliceFlag[T, S, E]) String() string |
| 1698 |
|
| 1699 |
func (x *SliceFlag[T, S, E]) TakesValue() bool |
| 1700 |
|
| 1701 |
type SliceFlagTarget[E any] interface { |
| 1702 |
Flag |
| 1703 |
RequiredFlag |
| 1704 |
DocGenerationFlag |
| 1705 |
VisibleFlag |
| 1706 |
CategorizableFlag |
| 1707 |
|
| 1708 |
// SetValue should propagate the given slice to the target, ideally as a new value. |
| 1709 |
// Note that a nil slice should nil/clear any existing value (modelled as ~[]E). |
| 1710 |
SetValue(slice []E) |
| 1711 |
// SetDestination should propagate the given slice to the target, ideally as a new value. |
| 1712 |
// Note that a nil slice should nil/clear any existing value (modelled as ~*[]E). |
| 1713 |
SetDestination(slice []E) |
| 1714 |
// GetDestination should return the current value referenced by any destination, or nil if nil/unset. |
| 1715 |
GetDestination() []E |
| 1716 |
} |
| 1717 |
SliceFlagTarget models a target implementation for use with SliceFlag. The |
| 1718 |
three methods, SetValue, SetDestination, and GetDestination, are necessary |
| 1719 |
to propagate Value and Destination, where Value is propagated inwards |
| 1720 |
(initially), and Destination is propagated outwards (on every update). |
| 1721 |
|
| 1722 |
type StringFlag struct { |
| 1723 |
Name string |
| 1724 |
|
| 1725 |
Category string |
| 1726 |
DefaultText string |
| 1727 |
FilePath string |
| 1728 |
Usage string |
| 1729 |
|
| 1730 |
Required bool |
| 1731 |
Hidden bool |
| 1732 |
HasBeenSet bool |
| 1733 |
|
| 1734 |
Value string |
| 1735 |
Destination *string |
| 1736 |
|
| 1737 |
Aliases []string |
| 1738 |
EnvVars []string |
| 1739 |
|
| 1740 |
TakesFile bool |
| 1741 |
|
| 1742 |
Action func(*Context, string) error |
| 1743 |
// Has unexported fields. |
| 1744 |
} |
| 1745 |
StringFlag is a flag with type string |
| 1746 |
|
| 1747 |
func (f *StringFlag) Apply(set *flag.FlagSet) error |
| 1748 |
Apply populates the flag given the flag set and environment |
| 1749 |
|
| 1750 |
func (f *StringFlag) Get(ctx *Context) string |
| 1751 |
Get returns the flag’s value in the given Context. |
| 1752 |
|
| 1753 |
func (f *StringFlag) GetCategory() string |
| 1754 |
GetCategory returns the category for the flag |
| 1755 |
|
| 1756 |
func (f *StringFlag) GetDefaultText() string |
| 1757 |
GetDefaultText returns the default text for this flag |
| 1758 |
|
| 1759 |
func (f *StringFlag) GetEnvVars() []string |
| 1760 |
GetEnvVars returns the env vars for this flag |
| 1761 |
|
| 1762 |
func (f *StringFlag) GetUsage() string |
| 1763 |
GetUsage returns the usage string for the flag |
| 1764 |
|
| 1765 |
func (f *StringFlag) GetValue() string |
| 1766 |
GetValue returns the flags value as string representation and an empty |
| 1767 |
string if the flag takes no value at all. |
| 1768 |
|
| 1769 |
func (f *StringFlag) IsRequired() bool |
| 1770 |
IsRequired returns whether or not the flag is required |
| 1771 |
|
| 1772 |
func (f *StringFlag) IsSet() bool |
| 1773 |
IsSet returns whether or not the flag has been set through env or file |
| 1774 |
|
| 1775 |
func (f *StringFlag) IsVisible() bool |
| 1776 |
IsVisible returns true if the flag is not hidden, otherwise false |
| 1777 |
|
| 1778 |
func (f *StringFlag) Names() []string |
| 1779 |
Names returns the names of the flag |
| 1780 |
|
| 1781 |
func (f *StringFlag) RunAction(c *Context) error |
| 1782 |
RunAction executes flag action if set |
| 1783 |
|
| 1784 |
func (f *StringFlag) String() string |
| 1785 |
String returns a readable representation of this value (for usage defaults) |
| 1786 |
|
| 1787 |
func (f *StringFlag) TakesValue() bool |
| 1788 |
TakesValue returns true of the flag takes a value, otherwise false |
| 1789 |
|
| 1790 |
type StringSlice struct { |
| 1791 |
// Has unexported fields. |
| 1792 |
} |
| 1793 |
StringSlice wraps a []string to satisfy flag.Value |
| 1794 |
|
| 1795 |
func NewStringSlice(defaults ...string) *StringSlice |
| 1796 |
NewStringSlice creates a *StringSlice with default values |
| 1797 |
|
| 1798 |
func (s *StringSlice) Get() interface{} |
| 1799 |
Get returns the slice of strings set by this flag |
| 1800 |
|
| 1801 |
func (s *StringSlice) Serialize() string |
| 1802 |
Serialize allows StringSlice to fulfill Serializer |
| 1803 |
|
| 1804 |
func (s *StringSlice) Set(value string) error |
| 1805 |
Set appends the string value to the list of values |
| 1806 |
|
| 1807 |
func (s *StringSlice) String() string |
| 1808 |
String returns a readable representation of this value (for usage defaults) |
| 1809 |
|
| 1810 |
func (s *StringSlice) Value() []string |
| 1811 |
Value returns the slice of strings set by this flag |
| 1812 |
|
| 1813 |
func (s *StringSlice) WithSeparatorSpec(spec separatorSpec) |
| 1814 |
|
| 1815 |
type StringSliceFlag struct { |
| 1816 |
Name string |
| 1817 |
|
| 1818 |
Category string |
| 1819 |
DefaultText string |
| 1820 |
FilePath string |
| 1821 |
Usage string |
| 1822 |
|
| 1823 |
Required bool |
| 1824 |
Hidden bool |
| 1825 |
HasBeenSet bool |
| 1826 |
|
| 1827 |
Value *StringSlice |
| 1828 |
Destination *StringSlice |
| 1829 |
|
| 1830 |
Aliases []string |
| 1831 |
EnvVars []string |
| 1832 |
|
| 1833 |
TakesFile bool |
| 1834 |
|
| 1835 |
Action func(*Context, []string) error |
| 1836 |
|
| 1837 |
KeepSpace bool |
| 1838 |
// Has unexported fields. |
| 1839 |
} |
| 1840 |
StringSliceFlag is a flag with type *StringSlice |
| 1841 |
|
| 1842 |
func (f *StringSliceFlag) Apply(set *flag.FlagSet) error |
| 1843 |
Apply populates the flag given the flag set and environment |
| 1844 |
|
| 1845 |
func (f *StringSliceFlag) Get(ctx *Context) []string |
| 1846 |
Get returns the flag’s value in the given Context. |
| 1847 |
|
| 1848 |
func (f *StringSliceFlag) GetCategory() string |
| 1849 |
GetCategory returns the category for the flag |
| 1850 |
|
| 1851 |
func (f *StringSliceFlag) GetDefaultText() string |
| 1852 |
GetDefaultText returns the default text for this flag |
| 1853 |
|
| 1854 |
func (f *StringSliceFlag) GetDestination() []string |
| 1855 |
|
| 1856 |
func (f *StringSliceFlag) GetEnvVars() []string |
| 1857 |
GetEnvVars returns the env vars for this flag |
| 1858 |
|
| 1859 |
func (f *StringSliceFlag) GetUsage() string |
| 1860 |
GetUsage returns the usage string for the flag |
| 1861 |
|
| 1862 |
func (f *StringSliceFlag) GetValue() string |
| 1863 |
GetValue returns the flags value as string representation and an empty |
| 1864 |
string if the flag takes no value at all. |
| 1865 |
|
| 1866 |
func (f *StringSliceFlag) IsRequired() bool |
| 1867 |
IsRequired returns whether or not the flag is required |
| 1868 |
|
| 1869 |
func (f *StringSliceFlag) IsSet() bool |
| 1870 |
IsSet returns whether or not the flag has been set through env or file |
| 1871 |
|
| 1872 |
func (f *StringSliceFlag) IsSliceFlag() bool |
| 1873 |
IsSliceFlag implements DocGenerationSliceFlag. |
| 1874 |
|
| 1875 |
func (f *StringSliceFlag) IsVisible() bool |
| 1876 |
IsVisible returns true if the flag is not hidden, otherwise false |
| 1877 |
|
| 1878 |
func (f *StringSliceFlag) Names() []string |
| 1879 |
Names returns the names of the flag |
| 1880 |
|
| 1881 |
func (f *StringSliceFlag) RunAction(c *Context) error |
| 1882 |
RunAction executes flag action if set |
| 1883 |
|
| 1884 |
func (f *StringSliceFlag) SetDestination(slice []string) |
| 1885 |
|
| 1886 |
func (f *StringSliceFlag) SetValue(slice []string) |
| 1887 |
|
| 1888 |
func (f *StringSliceFlag) String() string |
| 1889 |
String returns a readable representation of this value (for usage defaults) |
| 1890 |
|
| 1891 |
func (f *StringSliceFlag) TakesValue() bool |
| 1892 |
TakesValue returns true of the flag takes a value, otherwise false |
| 1893 |
|
| 1894 |
func (f *StringSliceFlag) WithSeparatorSpec(spec separatorSpec) |
| 1895 |
|
| 1896 |
type SuggestCommandFunc func(commands []*Command, provided string) string |
| 1897 |
|
| 1898 |
type SuggestFlagFunc func(flags []Flag, provided string, hideHelp bool) string |
| 1899 |
|
| 1900 |
type Timestamp struct { |
| 1901 |
// Has unexported fields. |
| 1902 |
} |
| 1903 |
Timestamp wrap to satisfy golang's flag interface. |
| 1904 |
|
| 1905 |
func NewTimestamp(timestamp time.Time) *Timestamp |
| 1906 |
Timestamp constructor |
| 1907 |
|
| 1908 |
func (t *Timestamp) Get() interface{} |
| 1909 |
Get returns the flag structure |
| 1910 |
|
| 1911 |
func (t *Timestamp) Set(value string) error |
| 1912 |
Parses the string value to timestamp |
| 1913 |
|
| 1914 |
func (t *Timestamp) SetLayout(layout string) |
| 1915 |
Set the timestamp string layout for future parsing |
| 1916 |
|
| 1917 |
func (t *Timestamp) SetLocation(loc *time.Location) |
| 1918 |
Set perceived timezone of the to-be parsed time string |
| 1919 |
|
| 1920 |
func (t *Timestamp) SetTimestamp(value time.Time) |
| 1921 |
Set the timestamp value directly |
| 1922 |
|
| 1923 |
func (t *Timestamp) String() string |
| 1924 |
String returns a readable representation of this value (for usage defaults) |
| 1925 |
|
| 1926 |
func (t *Timestamp) Value() *time.Time |
| 1927 |
Value returns the timestamp value stored in the flag |
| 1928 |
|
| 1929 |
type TimestampFlag struct { |
| 1930 |
Name string |
| 1931 |
|
| 1932 |
Category string |
| 1933 |
DefaultText string |
| 1934 |
FilePath string |
| 1935 |
Usage string |
| 1936 |
|
| 1937 |
Required bool |
| 1938 |
Hidden bool |
| 1939 |
HasBeenSet bool |
| 1940 |
|
| 1941 |
Value *Timestamp |
| 1942 |
Destination *Timestamp |
| 1943 |
|
| 1944 |
Aliases []string |
| 1945 |
EnvVars []string |
| 1946 |
|
| 1947 |
Layout string |
| 1948 |
|
| 1949 |
Timezone *time.Location |
| 1950 |
|
| 1951 |
Action func(*Context, *time.Time) error |
| 1952 |
// Has unexported fields. |
| 1953 |
} |
| 1954 |
TimestampFlag is a flag with type *Timestamp |
| 1955 |
|
| 1956 |
func (f *TimestampFlag) Apply(set *flag.FlagSet) error |
| 1957 |
Apply populates the flag given the flag set and environment |
| 1958 |
|
| 1959 |
func (f *TimestampFlag) Get(ctx *Context) *time.Time |
| 1960 |
Get returns the flag’s value in the given Context. |
| 1961 |
|
| 1962 |
func (f *TimestampFlag) GetCategory() string |
| 1963 |
GetCategory returns the category for the flag |
| 1964 |
|
| 1965 |
func (f *TimestampFlag) GetDefaultText() string |
| 1966 |
GetDefaultText returns the default text for this flag |
| 1967 |
|
| 1968 |
func (f *TimestampFlag) GetEnvVars() []string |
| 1969 |
GetEnvVars returns the env vars for this flag |
| 1970 |
|
| 1971 |
func (f *TimestampFlag) GetUsage() string |
| 1972 |
GetUsage returns the usage string for the flag |
| 1973 |
|
| 1974 |
func (f *TimestampFlag) GetValue() string |
| 1975 |
GetValue returns the flags value as string representation and an empty |
| 1976 |
string if the flag takes no value at all. |
| 1977 |
|
| 1978 |
func (f *TimestampFlag) IsRequired() bool |
| 1979 |
IsRequired returns whether or not the flag is required |
| 1980 |
|
| 1981 |
func (f *TimestampFlag) IsSet() bool |
| 1982 |
IsSet returns whether or not the flag has been set through env or file |
| 1983 |
|
| 1984 |
func (f *TimestampFlag) IsVisible() bool |
| 1985 |
IsVisible returns true if the flag is not hidden, otherwise false |
| 1986 |
|
| 1987 |
func (f *TimestampFlag) Names() []string |
| 1988 |
Names returns the names of the flag |
| 1989 |
|
| 1990 |
func (f *TimestampFlag) RunAction(c *Context) error |
| 1991 |
RunAction executes flag action if set |
| 1992 |
|
| 1993 |
func (f *TimestampFlag) String() string |
| 1994 |
String returns a readable representation of this value (for usage defaults) |
| 1995 |
|
| 1996 |
func (f *TimestampFlag) TakesValue() bool |
| 1997 |
TakesValue returns true of the flag takes a value, otherwise false |
| 1998 |
|
| 1999 |
type Uint64Flag struct { |
| 2000 |
Name string |
| 2001 |
|
| 2002 |
Category string |
| 2003 |
DefaultText string |
| 2004 |
FilePath string |
| 2005 |
Usage string |
| 2006 |
|
| 2007 |
Required bool |
| 2008 |
Hidden bool |
| 2009 |
HasBeenSet bool |
| 2010 |
|
| 2011 |
Value uint64 |
| 2012 |
Destination *uint64 |
| 2013 |
|
| 2014 |
Aliases []string |
| 2015 |
EnvVars []string |
| 2016 |
|
| 2017 |
Base int |
| 2018 |
|
| 2019 |
Action func(*Context, uint64) error |
| 2020 |
// Has unexported fields. |
| 2021 |
} |
| 2022 |
Uint64Flag is a flag with type uint64 |
| 2023 |
|
| 2024 |
func (f *Uint64Flag) Apply(set *flag.FlagSet) error |
| 2025 |
Apply populates the flag given the flag set and environment |
| 2026 |
|
| 2027 |
func (f *Uint64Flag) Get(ctx *Context) uint64 |
| 2028 |
Get returns the flag’s value in the given Context. |
| 2029 |
|
| 2030 |
func (f *Uint64Flag) GetCategory() string |
| 2031 |
GetCategory returns the category for the flag |
| 2032 |
|
| 2033 |
func (f *Uint64Flag) GetDefaultText() string |
| 2034 |
GetDefaultText returns the default text for this flag |
| 2035 |
|
| 2036 |
func (f *Uint64Flag) GetEnvVars() []string |
| 2037 |
GetEnvVars returns the env vars for this flag |
| 2038 |
|
| 2039 |
func (f *Uint64Flag) GetUsage() string |
| 2040 |
GetUsage returns the usage string for the flag |
| 2041 |
|
| 2042 |
func (f *Uint64Flag) GetValue() string |
| 2043 |
GetValue returns the flags value as string representation and an empty |
| 2044 |
string if the flag takes no value at all. |
| 2045 |
|
| 2046 |
func (f *Uint64Flag) IsRequired() bool |
| 2047 |
IsRequired returns whether or not the flag is required |
| 2048 |
|
| 2049 |
func (f *Uint64Flag) IsSet() bool |
| 2050 |
IsSet returns whether or not the flag has been set through env or file |
| 2051 |
|
| 2052 |
func (f *Uint64Flag) IsVisible() bool |
| 2053 |
IsVisible returns true if the flag is not hidden, otherwise false |
| 2054 |
|
| 2055 |
func (f *Uint64Flag) Names() []string |
| 2056 |
Names returns the names of the flag |
| 2057 |
|
| 2058 |
func (f *Uint64Flag) RunAction(c *Context) error |
| 2059 |
RunAction executes flag action if set |
| 2060 |
|
| 2061 |
func (f *Uint64Flag) String() string |
| 2062 |
String returns a readable representation of this value (for usage defaults) |
| 2063 |
|
| 2064 |
func (f *Uint64Flag) TakesValue() bool |
| 2065 |
TakesValue returns true of the flag takes a value, otherwise false |
| 2066 |
|
| 2067 |
type Uint64Slice struct { |
| 2068 |
// Has unexported fields. |
| 2069 |
} |
| 2070 |
Uint64Slice wraps []int64 to satisfy flag.Value |
| 2071 |
|
| 2072 |
func NewUint64Slice(defaults ...uint64) *Uint64Slice |
| 2073 |
NewUint64Slice makes an *Uint64Slice with default values |
| 2074 |
|
| 2075 |
func (i *Uint64Slice) Get() interface{} |
| 2076 |
Get returns the slice of ints set by this flag |
| 2077 |
|
| 2078 |
func (i *Uint64Slice) Serialize() string |
| 2079 |
Serialize allows Uint64Slice to fulfill Serializer |
| 2080 |
|
| 2081 |
func (i *Uint64Slice) Set(value string) error |
| 2082 |
Set parses the value into an integer and appends it to the list of values |
| 2083 |
|
| 2084 |
func (i *Uint64Slice) String() string |
| 2085 |
String returns a readable representation of this value (for usage defaults) |
| 2086 |
|
| 2087 |
func (i *Uint64Slice) Value() []uint64 |
| 2088 |
Value returns the slice of ints set by this flag |
| 2089 |
|
| 2090 |
func (i *Uint64Slice) WithSeparatorSpec(spec separatorSpec) |
| 2091 |
|
| 2092 |
type Uint64SliceFlag struct { |
| 2093 |
Name string |
| 2094 |
|
| 2095 |
Category string |
| 2096 |
DefaultText string |
| 2097 |
FilePath string |
| 2098 |
Usage string |
| 2099 |
|
| 2100 |
Required bool |
| 2101 |
Hidden bool |
| 2102 |
HasBeenSet bool |
| 2103 |
|
| 2104 |
Value *Uint64Slice |
| 2105 |
Destination *Uint64Slice |
| 2106 |
|
| 2107 |
Aliases []string |
| 2108 |
EnvVars []string |
| 2109 |
|
| 2110 |
Action func(*Context, []uint64) error |
| 2111 |
// Has unexported fields. |
| 2112 |
} |
| 2113 |
Uint64SliceFlag is a flag with type *Uint64Slice |
| 2114 |
|
| 2115 |
func (f *Uint64SliceFlag) Apply(set *flag.FlagSet) error |
| 2116 |
Apply populates the flag given the flag set and environment |
| 2117 |
|
| 2118 |
func (f *Uint64SliceFlag) Get(ctx *Context) []uint64 |
| 2119 |
Get returns the flag’s value in the given Context. |
| 2120 |
|
| 2121 |
func (f *Uint64SliceFlag) GetCategory() string |
| 2122 |
GetCategory returns the category for the flag |
| 2123 |
|
| 2124 |
func (f *Uint64SliceFlag) GetDefaultText() string |
| 2125 |
GetDefaultText returns the default text for this flag |
| 2126 |
|
| 2127 |
func (f *Uint64SliceFlag) GetEnvVars() []string |
| 2128 |
GetEnvVars returns the env vars for this flag |
| 2129 |
|
| 2130 |
func (f *Uint64SliceFlag) GetUsage() string |
| 2131 |
GetUsage returns the usage string for the flag |
| 2132 |
|
| 2133 |
func (f *Uint64SliceFlag) GetValue() string |
| 2134 |
GetValue returns the flags value as string representation and an empty |
| 2135 |
string if the flag takes no value at all. |
| 2136 |
|
| 2137 |
func (f *Uint64SliceFlag) IsRequired() bool |
| 2138 |
IsRequired returns whether or not the flag is required |
| 2139 |
|
| 2140 |
func (f *Uint64SliceFlag) IsSet() bool |
| 2141 |
IsSet returns whether or not the flag has been set through env or file |
| 2142 |
|
| 2143 |
func (f *Uint64SliceFlag) IsSliceFlag() bool |
| 2144 |
IsSliceFlag implements DocGenerationSliceFlag. |
| 2145 |
|
| 2146 |
func (f *Uint64SliceFlag) IsVisible() bool |
| 2147 |
IsVisible returns true if the flag is not hidden, otherwise false |
| 2148 |
|
| 2149 |
func (f *Uint64SliceFlag) Names() []string |
| 2150 |
Names returns the names of the flag |
| 2151 |
|
| 2152 |
func (f *Uint64SliceFlag) RunAction(c *Context) error |
| 2153 |
RunAction executes flag action if set |
| 2154 |
|
| 2155 |
func (f *Uint64SliceFlag) String() string |
| 2156 |
String returns a readable representation of this value (for usage defaults) |
| 2157 |
|
| 2158 |
func (f *Uint64SliceFlag) TakesValue() bool |
| 2159 |
TakesValue returns true of the flag takes a value, otherwise false |
| 2160 |
|
| 2161 |
func (f *Uint64SliceFlag) WithSeparatorSpec(spec separatorSpec) |
| 2162 |
|
| 2163 |
type UintFlag struct { |
| 2164 |
Name string |
| 2165 |
|
| 2166 |
Category string |
| 2167 |
DefaultText string |
| 2168 |
FilePath string |
| 2169 |
Usage string |
| 2170 |
|
| 2171 |
Required bool |
| 2172 |
Hidden bool |
| 2173 |
HasBeenSet bool |
| 2174 |
|
| 2175 |
Value uint |
| 2176 |
Destination *uint |
| 2177 |
|
| 2178 |
Aliases []string |
| 2179 |
EnvVars []string |
| 2180 |
|
| 2181 |
Base int |
| 2182 |
|
| 2183 |
Action func(*Context, uint) error |
| 2184 |
// Has unexported fields. |
| 2185 |
} |
| 2186 |
UintFlag is a flag with type uint |
| 2187 |
|
| 2188 |
func (f *UintFlag) Apply(set *flag.FlagSet) error |
| 2189 |
Apply populates the flag given the flag set and environment |
| 2190 |
|
| 2191 |
func (f *UintFlag) Get(ctx *Context) uint |
| 2192 |
Get returns the flag’s value in the given Context. |
| 2193 |
|
| 2194 |
func (f *UintFlag) GetCategory() string |
| 2195 |
GetCategory returns the category for the flag |
| 2196 |
|
| 2197 |
func (f *UintFlag) GetDefaultText() string |
| 2198 |
GetDefaultText returns the default text for this flag |
| 2199 |
|
| 2200 |
func (f *UintFlag) GetEnvVars() []string |
| 2201 |
GetEnvVars returns the env vars for this flag |
| 2202 |
|
| 2203 |
func (f *UintFlag) GetUsage() string |
| 2204 |
GetUsage returns the usage string for the flag |
| 2205 |
|
| 2206 |
func (f *UintFlag) GetValue() string |
| 2207 |
GetValue returns the flags value as string representation and an empty |
| 2208 |
string if the flag takes no value at all. |
| 2209 |
|
| 2210 |
func (f *UintFlag) IsRequired() bool |
| 2211 |
IsRequired returns whether or not the flag is required |
| 2212 |
|
| 2213 |
func (f *UintFlag) IsSet() bool |
| 2214 |
IsSet returns whether or not the flag has been set through env or file |
| 2215 |
|
| 2216 |
func (f *UintFlag) IsVisible() bool |
| 2217 |
IsVisible returns true if the flag is not hidden, otherwise false |
| 2218 |
|
| 2219 |
func (f *UintFlag) Names() []string |
| 2220 |
Names returns the names of the flag |
| 2221 |
|
| 2222 |
func (f *UintFlag) RunAction(c *Context) error |
| 2223 |
RunAction executes flag action if set |
| 2224 |
|
| 2225 |
func (f *UintFlag) String() string |
| 2226 |
String returns a readable representation of this value (for usage defaults) |
| 2227 |
|
| 2228 |
func (f *UintFlag) TakesValue() bool |
| 2229 |
TakesValue returns true of the flag takes a value, otherwise false |
| 2230 |
|
| 2231 |
type UintSlice struct { |
| 2232 |
// Has unexported fields. |
| 2233 |
} |
| 2234 |
UintSlice wraps []int to satisfy flag.Value |
| 2235 |
|
| 2236 |
func NewUintSlice(defaults ...uint) *UintSlice |
| 2237 |
NewUintSlice makes an *UintSlice with default values |
| 2238 |
|
| 2239 |
func (i *UintSlice) Get() interface{} |
| 2240 |
Get returns the slice of ints set by this flag |
| 2241 |
|
| 2242 |
func (i *UintSlice) Serialize() string |
| 2243 |
Serialize allows UintSlice to fulfill Serializer |
| 2244 |
|
| 2245 |
func (i *UintSlice) Set(value string) error |
| 2246 |
Set parses the value into an integer and appends it to the list of values |
| 2247 |
|
| 2248 |
func (i *UintSlice) SetUint(value uint) |
| 2249 |
TODO: Consistently have specific Set function for Int64 and Float64 ? SetInt |
| 2250 |
directly adds an integer to the list of values |
| 2251 |
|
| 2252 |
func (i *UintSlice) String() string |
| 2253 |
String returns a readable representation of this value (for usage defaults) |
| 2254 |
|
| 2255 |
func (i *UintSlice) Value() []uint |
| 2256 |
Value returns the slice of ints set by this flag |
| 2257 |
|
| 2258 |
func (i *UintSlice) WithSeparatorSpec(spec separatorSpec) |
| 2259 |
|
| 2260 |
type UintSliceFlag struct { |
| 2261 |
Name string |
| 2262 |
|
| 2263 |
Category string |
| 2264 |
DefaultText string |
| 2265 |
FilePath string |
| 2266 |
Usage string |
| 2267 |
|
| 2268 |
Required bool |
| 2269 |
Hidden bool |
| 2270 |
HasBeenSet bool |
| 2271 |
|
| 2272 |
Value *UintSlice |
| 2273 |
Destination *UintSlice |
| 2274 |
|
| 2275 |
Aliases []string |
| 2276 |
EnvVars []string |
| 2277 |
|
| 2278 |
Action func(*Context, []uint) error |
| 2279 |
// Has unexported fields. |
| 2280 |
} |
| 2281 |
UintSliceFlag is a flag with type *UintSlice |
| 2282 |
|
| 2283 |
func (f *UintSliceFlag) Apply(set *flag.FlagSet) error |
| 2284 |
Apply populates the flag given the flag set and environment |
| 2285 |
|
| 2286 |
func (f *UintSliceFlag) Get(ctx *Context) []uint |
| 2287 |
Get returns the flag’s value in the given Context. |
| 2288 |
|
| 2289 |
func (f *UintSliceFlag) GetCategory() string |
| 2290 |
GetCategory returns the category for the flag |
| 2291 |
|
| 2292 |
func (f *UintSliceFlag) GetDefaultText() string |
| 2293 |
GetDefaultText returns the default text for this flag |
| 2294 |
|
| 2295 |
func (f *UintSliceFlag) GetEnvVars() []string |
| 2296 |
GetEnvVars returns the env vars for this flag |
| 2297 |
|
| 2298 |
func (f *UintSliceFlag) GetUsage() string |
| 2299 |
GetUsage returns the usage string for the flag |
| 2300 |
|
| 2301 |
func (f *UintSliceFlag) GetValue() string |
| 2302 |
GetValue returns the flags value as string representation and an empty |
| 2303 |
string if the flag takes no value at all. |
| 2304 |
|
| 2305 |
func (f *UintSliceFlag) IsRequired() bool |
| 2306 |
IsRequired returns whether or not the flag is required |
| 2307 |
|
| 2308 |
func (f *UintSliceFlag) IsSet() bool |
| 2309 |
IsSet returns whether or not the flag has been set through env or file |
| 2310 |
|
| 2311 |
func (f *UintSliceFlag) IsSliceFlag() bool |
| 2312 |
IsSliceFlag implements DocGenerationSliceFlag. |
| 2313 |
|
| 2314 |
func (f *UintSliceFlag) IsVisible() bool |
| 2315 |
IsVisible returns true if the flag is not hidden, otherwise false |
| 2316 |
|
| 2317 |
func (f *UintSliceFlag) Names() []string |
| 2318 |
Names returns the names of the flag |
| 2319 |
|
| 2320 |
func (f *UintSliceFlag) RunAction(c *Context) error |
| 2321 |
RunAction executes flag action if set |
| 2322 |
|
| 2323 |
func (f *UintSliceFlag) String() string |
| 2324 |
String returns a readable representation of this value (for usage defaults) |
| 2325 |
|
| 2326 |
func (f *UintSliceFlag) TakesValue() bool |
| 2327 |
TakesValue returns true of the flag takes a value, otherwise false |
| 2328 |
|
| 2329 |
func (f *UintSliceFlag) WithSeparatorSpec(spec separatorSpec) |
| 2330 |
|
| 2331 |
type VisibleFlag interface { |
| 2332 |
Flag |
| 2333 |
|
| 2334 |
// IsVisible returns true if the flag is not hidden, otherwise false |
| 2335 |
IsVisible() bool |
| 2336 |
} |
| 2337 |
VisibleFlag is an interface that allows to check if a flag is visible |
| 2338 |
|
| 2339 |
type VisibleFlagCategory interface { |
| 2340 |
// Name returns the category name string |
| 2341 |
Name() string |
| 2342 |
// Flags returns a slice of VisibleFlag sorted by name |
| 2343 |
Flags() []VisibleFlag |
| 2344 |
} |
| 2345 |
VisibleFlagCategory is a category containing flags. |
| 2346 |
|
| 2347 |
package altsrc // import "github.com/urfave/cli/v2/altsrc" |
| 2348 |
|
| 2349 |
|
| 2350 |
FUNCTIONS |
| 2351 |
|
| 2352 |
func ApplyInputSourceValues(cCtx *cli.Context, inputSourceContext InputSourceContext, flags []cli.Flag) error |
| 2353 |
ApplyInputSourceValues iterates over all provided flags and executes |
| 2354 |
ApplyInputSourceValue on flags implementing the FlagInputSourceExtension |
| 2355 |
interface to initialize these flags to an alternate input source. |
| 2356 |
|
| 2357 |
func InitInputSource(flags []cli.Flag, createInputSource func() (InputSourceContext, error)) cli.BeforeFunc |
| 2358 |
InitInputSource is used to to setup an InputSourceContext on a cli.Command |
| 2359 |
Before method. It will create a new input source based on the func provided. |
| 2360 |
If there is no error it will then apply the new input source to any flags |
| 2361 |
that are supported by the input source |
| 2362 |
|
| 2363 |
func InitInputSourceWithContext(flags []cli.Flag, createInputSource func(cCtx *cli.Context) (InputSourceContext, error)) cli.BeforeFunc |
| 2364 |
InitInputSourceWithContext is used to to setup an InputSourceContext on |
| 2365 |
a cli.Command Before method. It will create a new input source based on |
| 2366 |
the func provided with potentially using existing cli.Context values to |
| 2367 |
initialize itself. If there is no error it will then apply the new input |
| 2368 |
source to any flags that are supported by the input source |
| 2369 |
|
| 2370 |
func NewJSONSourceFromFlagFunc(flag string) func(c *cli.Context) (InputSourceContext, error) |
| 2371 |
NewJSONSourceFromFlagFunc returns a func that takes a cli.Context and |
| 2372 |
returns an InputSourceContext suitable for retrieving config variables from |
| 2373 |
a file containing JSON data with the file name defined by the given flag. |
| 2374 |
|
| 2375 |
func NewTomlSourceFromFlagFunc(flagFileName string) func(cCtx *cli.Context) (InputSourceContext, error) |
| 2376 |
NewTomlSourceFromFlagFunc creates a new TOML InputSourceContext from a |
| 2377 |
provided flag name and source context. |
| 2378 |
|
| 2379 |
func NewYamlSourceFromFlagFunc(flagFileName string) func(cCtx *cli.Context) (InputSourceContext, error) |
| 2380 |
NewYamlSourceFromFlagFunc creates a new Yaml InputSourceContext from a |
| 2381 |
provided flag name and source context. |
| 2382 |
|
| 2383 |
|
| 2384 |
TYPES |
| 2385 |
|
| 2386 |
type BoolFlag struct { |
| 2387 |
*cli.BoolFlag |
| 2388 |
// Has unexported fields. |
| 2389 |
} |
| 2390 |
BoolFlag is the flag type that wraps cli.BoolFlag to allow for other values |
| 2391 |
to be specified |
| 2392 |
|
| 2393 |
func NewBoolFlag(fl *cli.BoolFlag) *BoolFlag |
| 2394 |
NewBoolFlag creates a new BoolFlag |
| 2395 |
|
| 2396 |
func (f *BoolFlag) Apply(set *flag.FlagSet) error |
| 2397 |
Apply saves the flagSet for later usage calls, then calls the wrapped |
| 2398 |
BoolFlag.Apply |
| 2399 |
|
| 2400 |
func (f *BoolFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error |
| 2401 |
ApplyInputSourceValue applies a Bool value to the flagSet if required |
| 2402 |
|
| 2403 |
type DurationFlag struct { |
| 2404 |
*cli.DurationFlag |
| 2405 |
// Has unexported fields. |
| 2406 |
} |
| 2407 |
DurationFlag is the flag type that wraps cli.DurationFlag to allow for other |
| 2408 |
values to be specified |
| 2409 |
|
| 2410 |
func NewDurationFlag(fl *cli.DurationFlag) *DurationFlag |
| 2411 |
NewDurationFlag creates a new DurationFlag |
| 2412 |
|
| 2413 |
func (f *DurationFlag) Apply(set *flag.FlagSet) error |
| 2414 |
Apply saves the flagSet for later usage calls, then calls the wrapped |
| 2415 |
DurationFlag.Apply |
| 2416 |
|
| 2417 |
func (f *DurationFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error |
| 2418 |
ApplyInputSourceValue applies a Duration value to the flagSet if required |
| 2419 |
|
| 2420 |
type FlagInputSourceExtension interface { |
| 2421 |
cli.Flag |
| 2422 |
ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error |
| 2423 |
} |
| 2424 |
FlagInputSourceExtension is an extension interface of cli.Flag that allows a |
| 2425 |
value to be set on the existing parsed flags. |
| 2426 |
|
| 2427 |
type Float64Flag struct { |
| 2428 |
*cli.Float64Flag |
| 2429 |
// Has unexported fields. |
| 2430 |
} |
| 2431 |
Float64Flag is the flag type that wraps cli.Float64Flag to allow for other |
| 2432 |
values to be specified |
| 2433 |
|
| 2434 |
func NewFloat64Flag(fl *cli.Float64Flag) *Float64Flag |
| 2435 |
NewFloat64Flag creates a new Float64Flag |
| 2436 |
|
| 2437 |
func (f *Float64Flag) Apply(set *flag.FlagSet) error |
| 2438 |
Apply saves the flagSet for later usage calls, then calls the wrapped |
| 2439 |
Float64Flag.Apply |
| 2440 |
|
| 2441 |
func (f *Float64Flag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error |
| 2442 |
ApplyInputSourceValue applies a Float64 value to the flagSet if required |
| 2443 |
|
| 2444 |
type Float64SliceFlag struct { |
| 2445 |
*cli.Float64SliceFlag |
| 2446 |
// Has unexported fields. |
| 2447 |
} |
| 2448 |
Float64SliceFlag is the flag type that wraps cli.Float64SliceFlag to allow |
| 2449 |
for other values to be specified |
| 2450 |
|
| 2451 |
func NewFloat64SliceFlag(fl *cli.Float64SliceFlag) *Float64SliceFlag |
| 2452 |
NewFloat64SliceFlag creates a new Float64SliceFlag |
| 2453 |
|
| 2454 |
func (f *Float64SliceFlag) Apply(set *flag.FlagSet) error |
| 2455 |
Apply saves the flagSet for later usage calls, then calls the wrapped |
| 2456 |
Float64SliceFlag.Apply |
| 2457 |
|
| 2458 |
func (f *Float64SliceFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error |
| 2459 |
ApplyInputSourceValue applies a Float64Slice value if required |
| 2460 |
|
| 2461 |
type GenericFlag struct { |
| 2462 |
*cli.GenericFlag |
| 2463 |
// Has unexported fields. |
| 2464 |
} |
| 2465 |
GenericFlag is the flag type that wraps cli.GenericFlag to allow for other |
| 2466 |
values to be specified |
| 2467 |
|
| 2468 |
func NewGenericFlag(fl *cli.GenericFlag) *GenericFlag |
| 2469 |
NewGenericFlag creates a new GenericFlag |
| 2470 |
|
| 2471 |
func (f *GenericFlag) Apply(set *flag.FlagSet) error |
| 2472 |
Apply saves the flagSet for later usage calls, then calls the wrapped |
| 2473 |
GenericFlag.Apply |
| 2474 |
|
| 2475 |
func (f *GenericFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error |
| 2476 |
ApplyInputSourceValue applies a generic value to the flagSet if required |
| 2477 |
|
| 2478 |
type InputSourceContext interface { |
| 2479 |
Source() string |
| 2480 |
|
| 2481 |
Int(name string) (int, error) |
| 2482 |
Int64(name string) (int64, error) |
| 2483 |
Uint(name string) (uint, error) |
| 2484 |
Uint64(name string) (uint64, error) |
| 2485 |
Duration(name string) (time.Duration, error) |
| 2486 |
Float64(name string) (float64, error) |
| 2487 |
String(name string) (string, error) |
| 2488 |
StringSlice(name string) ([]string, error) |
| 2489 |
IntSlice(name string) ([]int, error) |
| 2490 |
Int64Slice(name string) ([]int64, error) |
| 2491 |
Float64Slice(name string) ([]float64, error) |
| 2492 |
Generic(name string) (cli.Generic, error) |
| 2493 |
Bool(name string) (bool, error) |
| 2494 |
|
| 2495 |
// Has unexported methods. |
| 2496 |
} |
| 2497 |
InputSourceContext is an interface used to allow other input sources to be |
| 2498 |
implemented as needed. |
| 2499 |
|
| 2500 |
Source returns an identifier for the input source. In case of file source it |
| 2501 |
should return path to the file. |
| 2502 |
|
| 2503 |
func NewJSONSource(data []byte) (InputSourceContext, error) |
| 2504 |
NewJSONSource returns an InputSourceContext suitable for retrieving config |
| 2505 |
variables from raw JSON data. |
| 2506 |
|
| 2507 |
func NewJSONSourceFromFile(f string) (InputSourceContext, error) |
| 2508 |
NewJSONSourceFromFile returns an InputSourceContext suitable for retrieving |
| 2509 |
config variables from a file (or url) containing JSON data. |
| 2510 |
|
| 2511 |
func NewJSONSourceFromReader(r io.Reader) (InputSourceContext, error) |
| 2512 |
NewJSONSourceFromReader returns an InputSourceContext suitable for |
| 2513 |
retrieving config variables from an io.Reader that returns JSON data. |
| 2514 |
|
| 2515 |
func NewTomlSourceFromFile(file string) (InputSourceContext, error) |
| 2516 |
NewTomlSourceFromFile creates a new TOML InputSourceContext from a filepath. |
| 2517 |
|
| 2518 |
func NewYamlSourceFromFile(file string) (InputSourceContext, error) |
| 2519 |
NewYamlSourceFromFile creates a new Yaml InputSourceContext from a filepath. |
| 2520 |
|
| 2521 |
type Int64Flag struct { |
| 2522 |
*cli.Int64Flag |
| 2523 |
// Has unexported fields. |
| 2524 |
} |
| 2525 |
Int64Flag is the flag type that wraps cli.Int64Flag to allow for other |
| 2526 |
values to be specified |
| 2527 |
|
| 2528 |
func NewInt64Flag(fl *cli.Int64Flag) *Int64Flag |
| 2529 |
NewInt64Flag creates a new Int64Flag |
| 2530 |
|
| 2531 |
func (f *Int64Flag) Apply(set *flag.FlagSet) error |
| 2532 |
Apply saves the flagSet for later usage calls, then calls the wrapped |
| 2533 |
Int64Flag.Apply |
| 2534 |
|
| 2535 |
func (f *Int64Flag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error |
| 2536 |
|
| 2537 |
type Int64SliceFlag struct { |
| 2538 |
*cli.Int64SliceFlag |
| 2539 |
// Has unexported fields. |
| 2540 |
} |
| 2541 |
Int64SliceFlag is the flag type that wraps cli.Int64SliceFlag to allow for |
| 2542 |
other values to be specified |
| 2543 |
|
| 2544 |
func NewInt64SliceFlag(fl *cli.Int64SliceFlag) *Int64SliceFlag |
| 2545 |
NewInt64SliceFlag creates a new Int64SliceFlag |
| 2546 |
|
| 2547 |
func (f *Int64SliceFlag) Apply(set *flag.FlagSet) error |
| 2548 |
Apply saves the flagSet for later usage calls, then calls the wrapped |
| 2549 |
Int64SliceFlag.Apply |
| 2550 |
|
| 2551 |
func (f *Int64SliceFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error |
| 2552 |
ApplyInputSourceValue applies a Int64Slice value if required |
| 2553 |
|
| 2554 |
type IntFlag struct { |
| 2555 |
*cli.IntFlag |
| 2556 |
// Has unexported fields. |
| 2557 |
} |
| 2558 |
IntFlag is the flag type that wraps cli.IntFlag to allow for other values to |
| 2559 |
be specified |
| 2560 |
|
| 2561 |
func NewIntFlag(fl *cli.IntFlag) *IntFlag |
| 2562 |
NewIntFlag creates a new IntFlag |
| 2563 |
|
| 2564 |
func (f *IntFlag) Apply(set *flag.FlagSet) error |
| 2565 |
Apply saves the flagSet for later usage calls, then calls the wrapped |
| 2566 |
IntFlag.Apply |
| 2567 |
|
| 2568 |
func (f *IntFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error |
| 2569 |
ApplyInputSourceValue applies a int value to the flagSet if required |
| 2570 |
|
| 2571 |
type IntSliceFlag struct { |
| 2572 |
*cli.IntSliceFlag |
| 2573 |
// Has unexported fields. |
| 2574 |
} |
| 2575 |
IntSliceFlag is the flag type that wraps cli.IntSliceFlag to allow for other |
| 2576 |
values to be specified |
| 2577 |
|
| 2578 |
func NewIntSliceFlag(fl *cli.IntSliceFlag) *IntSliceFlag |
| 2579 |
NewIntSliceFlag creates a new IntSliceFlag |
| 2580 |
|
| 2581 |
func (f *IntSliceFlag) Apply(set *flag.FlagSet) error |
| 2582 |
Apply saves the flagSet for later usage calls, then calls the wrapped |
| 2583 |
IntSliceFlag.Apply |
| 2584 |
|
| 2585 |
func (f *IntSliceFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error |
| 2586 |
ApplyInputSourceValue applies a IntSlice value if required |
| 2587 |
|
| 2588 |
type MapInputSource struct { |
| 2589 |
// Has unexported fields. |
| 2590 |
} |
| 2591 |
MapInputSource implements InputSourceContext to return data from the map |
| 2592 |
that is loaded. |
| 2593 |
|
| 2594 |
func NewMapInputSource(file string, valueMap map[interface{}]interface{}) *MapInputSource |
| 2595 |
NewMapInputSource creates a new MapInputSource for implementing custom input |
| 2596 |
sources. |
| 2597 |
|
| 2598 |
func (fsm *MapInputSource) Bool(name string) (bool, error) |
| 2599 |
Bool returns an bool from the map otherwise returns false |
| 2600 |
|
| 2601 |
func (fsm *MapInputSource) Duration(name string) (time.Duration, error) |
| 2602 |
Duration returns a duration from the map if it exists otherwise returns 0 |
| 2603 |
|
| 2604 |
func (fsm *MapInputSource) Float64(name string) (float64, error) |
| 2605 |
Float64 returns an float64 from the map if it exists otherwise returns 0 |
| 2606 |
|
| 2607 |
func (fsm *MapInputSource) Float64Slice(name string) ([]float64, error) |
| 2608 |
Float64Slice returns an []float64 from the map if it exists otherwise |
| 2609 |
returns nil |
| 2610 |
|
| 2611 |
func (fsm *MapInputSource) Generic(name string) (cli.Generic, error) |
| 2612 |
Generic returns an cli.Generic from the map if it exists otherwise returns |
| 2613 |
nil |
| 2614 |
|
| 2615 |
func (fsm *MapInputSource) Int(name string) (int, error) |
| 2616 |
Int returns an int from the map if it exists otherwise returns 0 |
| 2617 |
|
| 2618 |
func (fsm *MapInputSource) Int64(name string) (int64, error) |
| 2619 |
Int64 returns an int64 from the map if it exists otherwise returns 0 |
| 2620 |
|
| 2621 |
func (fsm *MapInputSource) Int64Slice(name string) ([]int64, error) |
| 2622 |
Int64Slice returns an []int64 from the map if it exists otherwise returns |
| 2623 |
nil |
| 2624 |
|
| 2625 |
func (fsm *MapInputSource) IntSlice(name string) ([]int, error) |
| 2626 |
IntSlice returns an []int from the map if it exists otherwise returns nil |
| 2627 |
|
| 2628 |
func (fsm *MapInputSource) Source() string |
| 2629 |
Source returns the path of the source file |
| 2630 |
|
| 2631 |
func (fsm *MapInputSource) String(name string) (string, error) |
| 2632 |
String returns a string from the map if it exists otherwise returns an empty |
| 2633 |
string |
| 2634 |
|
| 2635 |
func (fsm *MapInputSource) StringSlice(name string) ([]string, error) |
| 2636 |
StringSlice returns an []string from the map if it exists otherwise returns |
| 2637 |
nil |
| 2638 |
|
| 2639 |
func (fsm *MapInputSource) Uint(name string) (uint, error) |
| 2640 |
Int64 returns an int64 from the map if it exists otherwise returns 0 |
| 2641 |
|
| 2642 |
func (fsm *MapInputSource) Uint64(name string) (uint64, error) |
| 2643 |
UInt64 returns an uint64 from the map if it exists otherwise returns 0 |
| 2644 |
|
| 2645 |
type PathFlag struct { |
| 2646 |
*cli.PathFlag |
| 2647 |
// Has unexported fields. |
| 2648 |
} |
| 2649 |
PathFlag is the flag type that wraps cli.PathFlag to allow for other values |
| 2650 |
to be specified |
| 2651 |
|
| 2652 |
func NewPathFlag(fl *cli.PathFlag) *PathFlag |
| 2653 |
NewPathFlag creates a new PathFlag |
| 2654 |
|
| 2655 |
func (f *PathFlag) Apply(set *flag.FlagSet) error |
| 2656 |
Apply saves the flagSet for later usage calls, then calls the wrapped |
| 2657 |
PathFlag.Apply |
| 2658 |
|
| 2659 |
func (f *PathFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error |
| 2660 |
ApplyInputSourceValue applies a Path value to the flagSet if required |
| 2661 |
|
| 2662 |
type StringFlag struct { |
| 2663 |
*cli.StringFlag |
| 2664 |
// Has unexported fields. |
| 2665 |
} |
| 2666 |
StringFlag is the flag type that wraps cli.StringFlag to allow for other |
| 2667 |
values to be specified |
| 2668 |
|
| 2669 |
func NewStringFlag(fl *cli.StringFlag) *StringFlag |
| 2670 |
NewStringFlag creates a new StringFlag |
| 2671 |
|
| 2672 |
func (f *StringFlag) Apply(set *flag.FlagSet) error |
| 2673 |
Apply saves the flagSet for later usage calls, then calls the wrapped |
| 2674 |
StringFlag.Apply |
| 2675 |
|
| 2676 |
func (f *StringFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error |
| 2677 |
ApplyInputSourceValue applies a String value to the flagSet if required |
| 2678 |
|
| 2679 |
type StringSliceFlag struct { |
| 2680 |
*cli.StringSliceFlag |
| 2681 |
// Has unexported fields. |
| 2682 |
} |
| 2683 |
StringSliceFlag is the flag type that wraps cli.StringSliceFlag to allow for |
| 2684 |
other values to be specified |
| 2685 |
|
| 2686 |
func NewStringSliceFlag(fl *cli.StringSliceFlag) *StringSliceFlag |
| 2687 |
NewStringSliceFlag creates a new StringSliceFlag |
| 2688 |
|
| 2689 |
func (f *StringSliceFlag) Apply(set *flag.FlagSet) error |
| 2690 |
Apply saves the flagSet for later usage calls, then calls the wrapped |
| 2691 |
StringSliceFlag.Apply |
| 2692 |
|
| 2693 |
func (f *StringSliceFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error |
| 2694 |
ApplyInputSourceValue applies a StringSlice value to the flagSet if required |
| 2695 |
|
| 2696 |
type Uint64Flag struct { |
| 2697 |
*cli.Uint64Flag |
| 2698 |
// Has unexported fields. |
| 2699 |
} |
| 2700 |
Uint64Flag is the flag type that wraps cli.Uint64Flag to allow for other |
| 2701 |
values to be specified |
| 2702 |
|
| 2703 |
func NewUint64Flag(fl *cli.Uint64Flag) *Uint64Flag |
| 2704 |
NewUint64Flag creates a new Uint64Flag |
| 2705 |
|
| 2706 |
func (f *Uint64Flag) Apply(set *flag.FlagSet) error |
| 2707 |
Apply saves the flagSet for later usage calls, then calls the wrapped |
| 2708 |
Uint64Flag.Apply |
| 2709 |
|
| 2710 |
func (f *Uint64Flag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error |
| 2711 |
|
| 2712 |
type UintFlag struct { |
| 2713 |
*cli.UintFlag |
| 2714 |
// Has unexported fields. |
| 2715 |
} |
| 2716 |
UintFlag is the flag type that wraps cli.UintFlag to allow for other values |
| 2717 |
to be specified |
| 2718 |
|
| 2719 |
func NewUintFlag(fl *cli.UintFlag) *UintFlag |
| 2720 |
NewUintFlag creates a new UintFlag |
| 2721 |
|
| 2722 |
func (f *UintFlag) Apply(set *flag.FlagSet) error |
| 2723 |
Apply saves the flagSet for later usage calls, then calls the wrapped |
| 2724 |
UintFlag.Apply |
| 2725 |
|
| 2726 |
func (f *UintFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error |
| 2727 |
|