veyron/lib/cmdline: Support pretty tabulation of the help message when commands
are >11 characters long.
Change-Id: I59ec00bee3f564e9b1e207762d0da46e93ee8b96
diff --git a/lib/cmdline/cmdline_test.go b/lib/cmdline/cmdline_test.go
index 370d478..e0de532 100644
--- a/lib/cmdline/cmdline_test.go
+++ b/lib/cmdline/cmdline_test.go
@@ -1956,3 +1956,45 @@
}
runTestCases(t, prog, tests)
}
+
+func TestLongCommandsHelp(t *testing.T) {
+ cmdLong := &Command{
+ Name: "thisisaverylongcommand",
+ Short: "description of very long command.",
+ Long: "blah blah blah.",
+ Run: runEcho,
+ }
+ cmdShort := &Command{
+ Name: "x",
+ Short: "description of short command.",
+ Long: "blah blah blah",
+ Run: runEcho,
+ }
+ prog := &Command{
+ Name: "program",
+ Short: "Test help strings when there are long commands.",
+ Long: "Test help strings when there are long commands.",
+ Children: []*Command{cmdShort, cmdLong},
+ }
+ var tests = []testCase{
+ {
+ Args: []string{"help"},
+ Stdout: `Test help strings when there are long commands.
+
+Usage:
+ program <command>
+
+The program commands are:
+ x description of short command.
+ thisisaverylongcommand description of very long command.
+ help Display help for commands or topics
+Run "program help [command]" for command usage.
+
+The global flags are:
+ -global1=: global test flag 1
+ -global2=0: global test flag 2
+`,
+ },
+ }
+ runTestCases(t, prog, tests)
+}