Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CLI help message broken when using subcommands (Issue/875) #876

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion hug/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,10 @@ def output_format(self, formatter):

def __str__(self):
output = "{0}\n\nAvailable Commands:\n\n".format(self.api.doc or self.api.name)
max_length = max((len(command_name) for command_name in self.commands))
for command_name, command in self.commands.items():
command_string = " - {}{}".format(
command_name, ": " + str(command).replace("\n", " ") if str(command) else ""
command_name.ljust(max_length+3), str(command).split('\n')[0] if str(command) else ""
)
output += command_string[:77] + "..." if len(command_string) > 80 else command_string
output += "\n"
Expand Down