MCPcopy Create free account
hub / github.com/apache/mesos / format_commands_help

Function format_commands_help

src/python/cli_new/lib/cli/util.py:117–136  ·  view source on GitHub ↗

Helps format plugin commands for display.

(cmds)

Source from the content-addressed store, hash-verified

115
116
117def format_commands_help(cmds):
118 """
119 Helps format plugin commands for display.
120 """
121 longest_cmd_name = max(list(cmds.keys()), key=len)
122
123 help_string = ""
124 for cmd in sorted(cmds.keys()):
125 # For the top-level entry point, `cmds` is a single-level
126 # dictionary with `short_help` as the values. For plugins,
127 # `cmds` is a two-level dictionary, where `short_help` is a
128 # field in each sub-dictionary.
129 short_help = cmds[cmd]
130 if isinstance(short_help, dict):
131 short_help = short_help["short_help"]
132
133 num_spaces = len(longest_cmd_name) - len(cmd) + 2
134 help_string += " %s%s%s\n" % (cmd, " " * num_spaces, short_help)
135
136 return help_string
137
138
139def format_subcommands_help(cmd):

Callers

nothing calls this directly

Calls 3

maxFunction · 0.85
listFunction · 0.50
keysMethod · 0.45

Tested by

no test coverage detected