Skip to content
Myr

Handle help arg by itself the same as no args

Before adoption: this commit came in with the history the project adopted, so no landing records it.

When the 'flask' command is used with only the '--help' parameter, this change will make sure to try and load the app before the help callback is run. This was previously only being done when the 'flask' command was used by itself. This meant when passing in '--help', any custom commands were not getting shown in the help message. With this change, custom commands will be included in the help message when running 'flask' on the command line by itself or with the '--help' parameter.

authored by George Waters · committed by David Lord · parent 08c480b · Browse files · 2 files+5 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+5 added−1 removed

  • other:+5 added−1 removed

2 files+5 added−1 removed

modified:src/flask/cli.py+3 added-1 removed
682 unmodified lines
683684 return super().make_context(info_name, args, parent=parent, **extra)685686 def parse_args(self, ctx: click.Context, args: list[str]) -> list[str]:687 if not args and self.no_args_is_help:687 if (not args and self.no_args_is_help) or (688 len(args) == 1 and args[0] in self.get_help_option_names(ctx)689 ):690 # Attempt to load --env-file and --app early in case they691 # were given as env vars. Otherwise no_args_is_help will not692 # see commands from app.cli.693 _env_file_option.handle_parse_result(ctx, {}, [])
442 unmodified lines
modified:CHANGES.rst+2 added
2 unmodified lines
34Unreleased56- Fix type hint for `cli_runner.invoke`. :issue:`5645`7- ``flask --help`` loads the app and plugins first to make sure all commands8 are shown. :issue:5673`91011Version 3.1.012-------------
1595 unmodified lines