diff --git a/commands/cli/helptext.go b/commands/cli/helptext.go index 3a82d58ad..2248e2699 100644 --- a/commands/cli/helptext.go +++ b/commands/cli/helptext.go @@ -36,18 +36,36 @@ func HelpText(rootName string, root *cmds.Command, path []string) (string, error } if cmd.Arguments != nil { - lines := indent(argumentText(cmd), " ") - s += fmt.Sprintf("Arguments:\n%v\n\n", strings.Join(lines, "\n")) + if len(cmd.ArgumentHelp) > 0 { + s += cmd.ArgumentHelp + } else { + section := strings.Join(indent(argumentText(cmd), " "), "\n") + s += fmt.Sprintf("Arguments:\n%v", section) + } + + s += "\n\n" } if cmd.Subcommands != nil { - lines := indent(subcommandText(cmd, rootName, path), " ") - s += fmt.Sprintf("Subcommands:\n%v\n\n", strings.Join(lines, "\n")) + if len(cmd.SubcommandHelp) > 0 { + s += cmd.SubcommandHelp + } else { + section := strings.Join(indent(subcommandText(cmd, rootName, path), " "), "\n") + s += fmt.Sprintf("Subcommands:\n%v", section) + } + + s += "\n\n" } if cmd.Options != nil { - lines := indent(optionText(cmd), " ") - s += fmt.Sprintf("Options:\n%v\n\n", strings.Join(lines, "\n")) + if len(cmd.OptionHelp) > 0 { + s += cmd.OptionHelp + } else { + section := strings.Join(indent(optionText(cmd), " "), "\n") + s += fmt.Sprintf("Options:\n%v", section) + } + + s += "\n\n" } return s, nil diff --git a/commands/command.go b/commands/command.go index 563b36024..6216c7fea 100644 --- a/commands/command.go +++ b/commands/command.go @@ -28,8 +28,13 @@ type Marshaller func(Response) ([]byte, error) // Command is a runnable command, with input arguments and options (flags). // It can also have Subcommands, to group units of work into sets. type Command struct { - Description string - Help string + // MAYBE_TODO: move all the text fields into a struct + // MAYBE_TODO: move these out of command and put them somewhere in commands/cli + Description string + Help string + SubcommandHelp string + OptionHelp string + ArgumentHelp string Options []Option Arguments []Argument