aboutsummaryrefslogtreecommitdiff
path: root/cmd/format.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/format.go')
-rw-r--r--cmd/format.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/cmd/format.go b/cmd/format.go
index 993b955..2953529 100644
--- a/cmd/format.go
+++ b/cmd/format.go
@@ -66,8 +66,8 @@ func init() {
}
}
-// MaxSubcommandLength returns the length of the longest subcommand (where the
-// length of the command is Name + Title). Return 0 if there aren't subcommands.
+// MaxNameLength returns the length of the longest subcommand Name. Return 0 if
+// there aren't subcommands.
func (c *Command) MaxNameLength() (max int) {
for _, s := range c.SubCommands {
max = util.MaxInt(max, len(s.Name))
@@ -75,6 +75,15 @@ func (c *Command) MaxNameLength() (max int) {
return
}
+// MaxTitleLength returns the length of the longest subcommand Title. Return 0
+// if there aren't subcommands.
+func (c *Command) MaxTitleLength() (max int) {
+ for _, s := range c.SubCommands {
+ max = util.MaxInt(max, len(s.Title))
+ }
+ return
+}
+
// WrapText wraps an input string so that each line begins with numTabs tabs
// (except the first line) and ends with a newline (except the last line), and
// each line has length less than lineLength. If the text contains a word which