Skip to content

Commit

Permalink
Add Examples field to SuperCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
barrettj12 committed Aug 14, 2023
1 parent d24b33f commit 9137ebd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
1 change: 0 additions & 1 deletion documentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ func (c *documentationCommand) readFileIds(path string) (map[string]string, erro
return ids, nil
}

// TODO: handle subcommands here
func (c *documentationCommand) dumpEntries(writer *bufio.Writer) error {
if len(c.super.subcmds) == 0 {
fmt.Printf("No commands found for %s", c.super.Name)
Expand Down
20 changes: 12 additions & 8 deletions supercommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ type SuperCommandParams struct {
// in the help output.
NotifyHelp func([]string)

Name string
Purpose string
Doc string
Name string
Purpose string
Doc string
Examples string
// Log holds the Log value associated with the supercommand. If it's nil,
// no logging flags will be configured.
Log *Log
Expand Down Expand Up @@ -113,11 +114,12 @@ type FlagAdder interface {
// the fully initialized structure.
func NewSuperCommand(params SuperCommandParams) *SuperCommand {
command := &SuperCommand{
Name: params.Name,
Purpose: params.Purpose,
Doc: params.Doc,
Log: params.Log,
Aliases: params.Aliases,
Name: params.Name,
Purpose: params.Purpose,
Doc: params.Doc,
Examples: params.Examples,
Log: params.Log,
Aliases: params.Aliases,

globalFlags: params.GlobalFlags,
usagePrefix: params.UsagePrefix,
Expand Down Expand Up @@ -162,6 +164,7 @@ type SuperCommand struct {
Name string
Purpose string
Doc string
Examples string
Log *Log
Aliases []string
globalFlags FlagAdder
Expand Down Expand Up @@ -361,6 +364,7 @@ func (c *SuperCommand) Info() *Info {
Purpose: c.Purpose,
Doc: strings.TrimSpace(c.Doc),
Subcommands: c.describeCommands(),
Examples: c.Examples,
Aliases: c.Aliases,
FlagKnownAs: c.FlagKnownAs,
}
Expand Down

0 comments on commit 9137ebd

Please sign in to comment.