Command: Presetting Args
Preset Args
Injecting args to a command
.PresetCmdLines(args...)
can be used to provide presetting args for a command. These args will be injected into the tail of the command, which need not inputed by end-user.
For instence, supposing a subcmd preset/cmd
has preset args -pv
,then the inputing app preset cmd
would be treated as app preset cmd -p -v
.
Definitions
The examples/demo/
showes howto using Preset Args
, in cmd/preset.go
:
Run
The result of the example app is,
The OnAction
handler of preset cmd
subcmd invoked the cmdr builtin defaultAction, which will print the debugging information.
In Matched commands
section, the noteable things are all matched subcmds are listed here. And, the matched flags will be listed at Matched flags
section. A fact shown, the flag p
and v
are both in the list even thought they are not inputted by end-user explicitly.
额外的话题
How is this guide?
Last updated on