Add aliases to ALL help output (#191)

This commit is contained in:
Nikita Semikov
2021-08-07 15:04:51 +03:00
committed by GitHub
parent 676890f22f
commit f547618963
2 changed files with 8 additions and 5 deletions
+5 -5
View File
@@ -342,7 +342,7 @@ Run "test-app <command> --help" for more information on a command.
require.NoError(t, err)
})
require.True(t, exited)
expected := `Usage: test-app one <command>
expected := `Usage: test-app one (un,uno) <command>
subcommand one
@@ -414,7 +414,7 @@ Commands:
two Another subcommand.
Group A
one subcommand one
one (un,uno) subcommand one
Run "test-app <command> --help" for more information on a command.
`
@@ -432,7 +432,7 @@ Run "test-app <command> --help" for more information on a command.
require.NoError(t, err)
})
require.True(t, exited)
expected := `Usage: test-app one <command>
expected := `Usage: test-app one (un,uno) <command>
subcommand one
@@ -440,8 +440,8 @@ Flags:
-h, --help Show context-sensitive help.
Group A
one thing subcommand thing
one <other> subcommand other
one (un,uno) thing subcommand thing
one (un,uno) <other> subcommand other
`
if expected != w.String() {
t.Errorf("help command returned:\n%v\n\nwant:\n%v", w.String(), expected)
+3
View File
@@ -204,6 +204,9 @@ func (n *Node) Path() (out string) {
switch n.Type {
case CommandNode:
out += " " + n.Name
if len(n.Aliases) > 0 {
out += fmt.Sprintf(" (%s)", strings.Join(n.Aliases, ","))
}
case ArgumentNode:
out += " " + "<" + n.Name + ">"
default: