You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by kl...@apache.org on 2018/10/20 10:52:54 UTC

[mesos] 01/02: Fixed formatting in subcommand help in the new CLI.

This is an automated email from the ASF dual-hosted git repository.

klueska pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 28bff37977f18976e75786fad987faf11b96f91a
Author: Kevin Klues <kl...@gmail.com>
AuthorDate: Sat Oct 20 05:27:31 2018 -0400

    Fixed formatting in subcommand help in the new CLI.
    
    Previously, there was some weird formatting with extra newlines when
    providing multi-line 'long_help' strings or extra flags to the
    subcommands. This commit fixes that.
    
    Review: https://reviews.apache.org/r/69104
---
 src/python/cli_new/lib/cli/util.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/python/cli_new/lib/cli/util.py b/src/python/cli_new/lib/cli/util.py
index 6a01236..b1181c2 100644
--- a/src/python/cli_new/lib/cli/util.py
+++ b/src/python/cli_new/lib/cli/util.py
@@ -143,7 +143,7 @@ def format_subcommands_help(cmd):
     arguments = " ".join(cmd["arguments"])
     short_help = cmd["short_help"]
     long_help = textwrap.dedent(cmd["long_help"].rstrip())
-    long_help = "  " + "\n  ".join(long_help.split('\n'))
+    long_help = "  " + "\n  ".join(long_help.lstrip().split('\n'))
     flags = cmd["flags"]
     flags["-h --help"] = "Show this screen."
     flag_string = ""
@@ -153,6 +153,7 @@ def format_subcommands_help(cmd):
         for flag in sorted(flags.keys()):
             num_spaces = len(longest_flag_name) - len(flag) + 2
             flag_string += "  %s%s%s\n" % (flag, " " * num_spaces, flags[flag])
+    flag_string = flag_string.rstrip()
 
     return (arguments, short_help, long_help, flag_string)