Skip to content

Commit

Permalink
Merge pull request #3 from yingzhuo/master
Browse files Browse the repository at this point in the history
add see also for sub command
  • Loading branch information
subchen committed Oct 29, 2019
2 parents 881340b + 63452ae commit 73402d8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ type Command struct {
Description string
// Examples of the program
Examples string
// SeeAlso of the program
SeeAlso string

// List of flags to parse
Flags []*Flag
Expand Down
4 changes: 3 additions & 1 deletion help.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ COMMANDS:
EXAMPLES:
{{- range .ExampleLines}}
{{.}}
{{- end}}{{end}}{{if .SeeAlsoLines }}
{{- end}}{{end}}{{if .SeeAlsoLines}}
SEE ALSO:
{{- range .SeeAlsoLines}}
Expand Down Expand Up @@ -94,6 +94,7 @@ func newCommandHelpContext(name string, cmd *Command, app *App) *HelpContext {
UsageText: cmd.UsageText,
Description: cmd.Description,
Examples: cmd.Examples,
SeeAlso: cmd.SeeAlso,
Flags: cmd.Flags,
Commands: cmd.Commands,
}
Expand Down Expand Up @@ -180,6 +181,7 @@ func (c *HelpContext) ExampleLines() []string {
return examples
}

// SeeAlsoLines splits line for see also
func (c *HelpContext) SeeAlsoLines() []string {
c.SeeAlso = strings.TrimSpace(c.SeeAlso)
if len(c.SeeAlso) == 0 {
Expand Down
1 change: 1 addition & 0 deletions help_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func TestHelpShowHelp(t *testing.T) {
IsBool: true,
},
},
SeeAlso: "https://github.com/subchen/go-cli#build\nhttps://github.com/subchen/go-cli#build2",
},
{
Name: "release",
Expand Down

0 comments on commit 73402d8

Please sign in to comment.