Skip to content

Commit

Permalink
Merge pull request #1404 from ewels/help-h-flag
Browse files Browse the repository at this point in the history
Use `-h` as a help flag
  • Loading branch information
ewels authored Feb 10, 2022
2 parents 4fb725b + ee9573f commit b2f59b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
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

0 comments on commit b2f59b7

Please sign in to comment.