feat(bonfire): add Passthrough and Long command fields
- Command.Passthrough turns off cobra flag parsing and uses arbitrary args, so every argument after the command name, including --help, -h and --, reaches Run through Input.Args unchanged - Command.Long sets cobra's Long text for the help command; without it the description is shown as before - both fields are additive: commands without Passthrough parse flags and reject unknown ones exactly as before - README and docs/console/writing-commands.md describe both fields
This commit is contained in:
@@ -15,6 +15,17 @@ var ErrCommandName = errors.New("bonfire: plugin command name must be namespace:
|
||||
type Command struct {
|
||||
Name string
|
||||
Description string
|
||||
// Long is optional extended help that cobra shows for the help command
|
||||
// (help <command>). When empty, cobra falls back to Description.
|
||||
Long string
|
||||
// Passthrough turns off flag parsing for the command: every argument
|
||||
// after the command name, including --help, -h and --, reaches Run
|
||||
// unchanged through Input.Args. Declared Flags are registered for the
|
||||
// usage text only and are never parsed, so Input.Flag returns only
|
||||
// their defaults. Declared Args shape the usage string but are not
|
||||
// count-checked, so Input.Argument indexes the raw args. Passthrough
|
||||
// suits wrapper commands that forward to another program.
|
||||
Passthrough bool
|
||||
Flags []Flag
|
||||
Args []Arg
|
||||
Run func(ctx context.Context, in Input, out Output) error
|
||||
|
||||
Reference in New Issue
Block a user