Skip to content

Commit

Permalink
Skip arguments, only print options
Browse files Browse the repository at this point in the history
  • Loading branch information
ewels committed Feb 9, 2022
1 parent f849d99 commit 2351867
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions nf_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ class OptionHighlighter(RegexHighlighter):

# Print the option flags
options_table = Table(highlight=True, box=None, show_header=False)
for param in obj.get_params(ctx)[1:]:
for param in obj.get_params(ctx):

# Skip positional arguments - they don't have opts or helptext and are covered in usage
# See https://click.palletsprojects.com/en/8.0.x/documentation/#documenting-arguments
if type(param) is click.core.Argument:
continue

# Short and long form
if len(param.opts) == 2:
opt1 = highlighter(param.opts[1])
Expand All @@ -150,14 +156,15 @@ class OptionHighlighter(RegexHighlighter):
help = Text.from_markup(param.get_help_record(ctx)[-1], emoji=False)

options_table.add_row(highlighter(opt1), highlighter(opt2), metavar, highlighter(help))
console.print(Panel(options_table, border_style="dim", title="Options", title_align="left", width=100))

if options_table.row_count > 0:
console.print(Panel(options_table, border_style="dim", title="Options", title_align="left", width=100))

# List click command groups
if hasattr(obj, "list_commands"):
commands_table = Table(highlight=False, box=None, show_header=False)
# Define formatting in columns, as commands don't match highlighter regex
commands_table.add_column("Command", style="bold cyan", no_wrap=True)
commands_table.add_column("Description")
# Define formatting in first column, as commands don't match highlighter regex
commands_table.add_column(style="bold cyan", no_wrap=True)
for command in obj.list_commands(ctx):
cmd = obj.get_command(ctx, command)
commands_table.add_row(command, highlighter(cmd.help.split("\n")[0]))
Expand Down

0 comments on commit 2351867

Please sign in to comment.