(
self,
add_default_commands: bool = True,
create_app: t.Callable[..., Flask] | None = None,
add_version_option: bool = True,
load_dotenv: bool = True,
set_debug_flag: bool = True,
**extra: t.Any,
)
| 561 | """ |
| 562 | |
| 563 | def __init__( |
| 564 | self, |
| 565 | add_default_commands: bool = True, |
| 566 | create_app: t.Callable[..., Flask] | None = None, |
| 567 | add_version_option: bool = True, |
| 568 | load_dotenv: bool = True, |
| 569 | set_debug_flag: bool = True, |
| 570 | **extra: t.Any, |
| 571 | ) -> None: |
| 572 | params: list[click.Parameter] = list(extra.pop("params", None) or ()) |
| 573 | # Processing is done with option callbacks instead of a group |
| 574 | # callback. This allows users to make a custom group callback |
| 575 | # without losing the behavior. --env-file must come first so |
| 576 | # that it is eagerly evaluated before --app. |
| 577 | params.extend((_env_file_option, _app_option, _debug_option)) |
| 578 | |
| 579 | if add_version_option: |
| 580 | params.append(version_option) |
| 581 | |
| 582 | if "context_settings" not in extra: |
| 583 | extra["context_settings"] = {} |
| 584 | |
| 585 | extra["context_settings"].setdefault("auto_envvar_prefix", "FLASK") |
| 586 | |
| 587 | super().__init__(params=params, **extra) |
| 588 | |
| 589 | self.create_app = create_app |
| 590 | self.load_dotenv = load_dotenv |
| 591 | self.set_debug_flag = set_debug_flag |
| 592 | |
| 593 | if add_default_commands: |
| 594 | self.add_command(run_command) |
| 595 | self.add_command(shell_command) |
| 596 | self.add_command(routes_command) |
| 597 | |
| 598 | self._loaded_plugin_commands = False |
| 599 | |
| 600 | def _load_plugin_commands(self) -> None: |
| 601 | if self._loaded_plugin_commands: |
nothing calls this directly
no test coverage detected