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

Use -h as a help flag #1404

Merged
merged 2 commits into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* Adds Gitpod environment to template.
* Adds Gitpod environment to tools with auto build of nf-core tool.
* Shiny new command-line help formatting ([#1403](https://github.com/nf-core/tools/pull/1403))
* Call the command line help with `-h` as well as `--help` (was formerly just the latter) ([#1404](https://github.com/nf-core/tools/pull/1404))

### Modules

Expand Down
15 changes: 10 additions & 5 deletions nf_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,13 @@ class OptionHighlighter(RegexHighlighter):

# Short and long form
if len(param.opts) == 2:
opt1 = highlighter(param.opts[1])
opt2 = highlighter(param.opts[0])
# Always have the --long form first
if "--" in param.opts[0]:
opt1 = highlighter(param.opts[0])
opt2 = highlighter(param.opts[1])
else:
opt1 = highlighter(param.opts[1])
opt2 = highlighter(param.opts[0])
# Just one form
else:
opt1 = highlighter(param.opts[0])
Expand Down Expand Up @@ -228,7 +233,7 @@ def format_help(self, ctx, formatter):
rich_format_help(self, ctx, formatter)


@click.group(cls=CustomHelpOrder)
@click.group(cls=CustomHelpOrder, context_settings=dict(help_option_names=["-h", "--help"]))
@click.version_option(nf_core.__version__)
@click.option("-v", "--verbose", is_flag=True, default=False, help="Print verbose output to the console.")
@click.option("-l", "--log-file", help="Save a verbose log to a file.", metavar="<filename>")
Expand Down Expand Up @@ -299,10 +304,10 @@ def list(keywords, sort, json, show_archived):
"-a", "--save-all", is_flag=True, default=False, help="Save all parameters, even if unchanged from default"
)
@click.option(
"-h", "--show-hidden", is_flag=True, default=False, help="Show hidden params which don't normally need changing"
"-x", "--show-hidden", is_flag=True, default=False, help="Show hidden params which don't normally need changing"
)
@click.option(
"--url", type=str, default="https://nf-co.re/launch", help="Customise the builder URL (for development work)"
"-u", "--url", type=str, default="https://nf-co.re/launch", help="Customise the builder URL (for development work)"
)
def launch(pipeline, id, revision, command_only, params_in, params_out, save_all, show_hidden, url):
"""
Expand Down