INNER CODE UNIT · Python
format_commands
iterative/mlem · mlem/cli/main.py:273
def format_commands(self, ctx: Context, formatter: HelpFormatter) -> None:
commands = []
for subcommand in self.list_commands(ctx):
cmd = self.get_command(ctx, subcommand)
# What is this, the tool lied about a command. Ignore it
if cmd is None:
continue
if cmd.hidden:
continue
commands.append((subcommand, cmd))
# allow for 3 times the default spacing
if len(commands) > 0:
limit = formatter.width - 6 - max(len(cmd[0]) for cmd in commands)
sections = defaultdict(list)
for subcommand, cmd in commands: