feat(bonfire): Artisan help, examples, JSON listing and error hints
- help <command> and <command> --help print Description, Usage,
Arguments, Options with defaults, Global options, Help and Examples
- Command.Examples and Command.Hidden (appended, additive); list --all
shows hidden commands, list --format=json prints a bonfire.Listing
- CheckDocs reports commands lacking description, long help, examples or
argument and option descriptions
- Error block with the ERROR badge, WithHint explanation and Try lines
({bin} replaced), cobra suggestions as Try, -v error chain, messages
scrubbed by sunscreen; Reported errors print nothing and exit 1
This commit is contained in:
@@ -15,8 +15,8 @@ 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 is optional extended help, shown under "Help:" by help
|
||||
// <command> and <command> --help.
|
||||
Long string
|
||||
// Passthrough turns off flag parsing for the command: every argument
|
||||
// after the command name, including --help, -h and --, reaches Run
|
||||
@@ -29,6 +29,22 @@ type Command struct {
|
||||
Flags []Flag
|
||||
Args []Arg
|
||||
Run func(ctx context.Context, in Input, out Output) error
|
||||
// Examples are shown under "Examples:" in the command's help and in
|
||||
// the JSON listing, each as a "#" comment and the command line.
|
||||
Examples []Example
|
||||
// Hidden keeps a runnable command out of the list; list --all and the
|
||||
// JSON listing still show it.
|
||||
Hidden bool
|
||||
}
|
||||
|
||||
// Example is one usage example of a command.
|
||||
type Example struct {
|
||||
// Command is the command line without the binary, for example
|
||||
// "admin:token:create jane --json"; help prints it after summer or
|
||||
// bin/<name>.
|
||||
Command string
|
||||
// Description is a short sentence shown as a "#" comment above it.
|
||||
Description string
|
||||
}
|
||||
|
||||
// Flag describes a string flag passed to a command.
|
||||
|
||||
Reference in New Issue
Block a user