From 81b3680908e95d7b887250feb72b19a2dd6c2ec6 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Thu, 13 Nov 2014 00:37:48 -0800 Subject: [PATCH] cmds2: aligned subcmd text --- commands/cli/helptext.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/commands/cli/helptext.go b/commands/cli/helptext.go index 3c6a00473..9ac20c820 100644 --- a/commands/cli/helptext.go +++ b/commands/cli/helptext.go @@ -277,6 +277,7 @@ func subcommandText(cmd *cmds.Command, rootName string, path []string) []string if len(path) > 0 { prefix += " " } + subcmds := make([]*cmds.Command, len(cmd.Subcommands)) lines := make([]string, len(cmd.Subcommands)) i := 0 @@ -285,10 +286,16 @@ func subcommandText(cmd *cmds.Command, rootName string, path []string) []string if len(usage) > 0 { usage = " " + usage } - lines[i] = fmt.Sprintf("%v%v%v - %v", prefix, name, usage, sub.Helptext.Tagline) + lines[i] = prefix + name + usage + subcmds[i] = sub i++ } + lines = align(lines) + for i, sub := range subcmds { + lines[i] += " - " + sub.Helptext.Tagline + } + return lines }