From f547618963602ee3a6b092d84f1e4485a69f8b7f Mon Sep 17 00:00:00 2001 From: Nikita Semikov <11590371+nsemikov@users.noreply.github.com> Date: Sat, 7 Aug 2021 15:04:51 +0300 Subject: [PATCH] Add aliases to ALL help output (#191) --- help_test.go | 10 +++++----- model.go | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/help_test.go b/help_test.go index 97c8d7b..728681e 100644 --- a/help_test.go +++ b/help_test.go @@ -342,7 +342,7 @@ Run "test-app --help" for more information on a command. require.NoError(t, err) }) require.True(t, exited) - expected := `Usage: test-app one + expected := `Usage: test-app one (un,uno) subcommand one @@ -414,7 +414,7 @@ Commands: two Another subcommand. Group A - one subcommand one + one (un,uno) subcommand one Run "test-app --help" for more information on a command. ` @@ -432,7 +432,7 @@ Run "test-app --help" for more information on a command. require.NoError(t, err) }) require.True(t, exited) - expected := `Usage: test-app one + expected := `Usage: test-app one (un,uno) subcommand one @@ -440,8 +440,8 @@ Flags: -h, --help Show context-sensitive help. Group A - one thing subcommand thing - one subcommand other + one (un,uno) thing subcommand thing + one (un,uno) subcommand other ` if expected != w.String() { t.Errorf("help command returned:\n%v\n\nwant:\n%v", w.String(), expected) diff --git a/model.go b/model.go index e0263d7..aed7c35 100644 --- a/model.go +++ b/model.go @@ -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: