Skip to content
Myr

Simplified click integration a bit

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

authored by Armin Ronacher · committed by Armin Ronacher · parent 32d3224 · Browse files · 2 files+14 added−28 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+14 added−28 removed

  • other:+14 added−28 removed

2 files+14 added−28 removed

modified:flask/app.py+2 added-2 removed
9 unmodified lines
10"""1112import os13import sys14import click15from threading import Lock16from datetime import timedelta17from itertools import chain18from functools import update_wrapper
15 unmodified lines
34from .templating import DispatchingJinjaLoader, Environment, \35 _default_template_ctx_processor36from .signals import request_started, request_finished, got_request_exception, \37 request_tearing_down, appcontext_tearing_down37from .cli import make_default_cli38from ._compat import reraise, string_types, text_type, integer_types3940# a lock used for logger initialization41_logger_lock = Lock()
501 unmodified lines
543 #: application has been discovered. The default commands are544 #: provided by Flask itself and can be overridden.545 #:546 #: This is an instance of a :class:`click.Group` object.547 self.cli = make_default_cli(self)547 self.cli = click.Group(self)548549 def _get_error_handlers(self):550 from warnings import warn551 warn(DeprecationWarning('error_handlers is deprecated, use the '
1372 unmodified lines
modified:flask/cli.py+12 added-26 removed
129 unmodified lines
130 rv = self._load_unlocked()131 return rv(environ, start_response)132133134def _no_such_app():135 raise NoAppException('Could not locate Flask application. '136 'You did not provide FLASK_APP or the '137 '--app parameter.')138139134class ScriptInfo(object):135 """Help object to deal with Flask applications. This is usually not136 necessary to interface with as it's used internally in the dispatching137 to click.
23 unmodified lines
161 if self.create_app is not None:162 rv = self.create_app(self)163 else:164 if self.app_import_path is None:171 _no_such_app()165 raise NoAppException('Could not locate Flask application. '166 'You did not provide FLASK_APP or the '167 '--app parameter.')168 rv = locate_app(self.app_import_path)169 if self.debug is not None:170 rv.debug = self.debug171 self._loaded_app = rv
241 unmodified lines
413 )414 code.interact(banner=banner, local=app.make_shell_context())415416421def make_default_cli(app):422 """Creates the default click object for the app itself. Currently423 there are no default commands registered because all builtin commands424 are registered on the actual cmd object here.425 """426 return click.Group()417cli = FlaskGroup(help="""\418This shell command acts as general utility script for Flask applications.419420It loads the application configured (either through the FLASK_APP environment421variable or the --app parameter) and then provides commands either provided422by the application or Flask itself.423429@click.group(cls=FlaskGroup)430def cli(**params):431 """432 This shell command acts as general utility script for Flask applications.424The most useful commands are the "run" and "shell" command.425434 It loads the application configured (either through the FLASK_APP environment435 variable or the --app parameter) and then provides commands either provided436 by the application or Flask itself.426Example usage:427438 The most useful commands are the "run" and "shell" command.428 flask --app=hello --debug run429""")430440 Example usage:431442 flask --app=hello --debug run443 """444445432def main(as_module=False):433 this_module = __package__ + '.cli'434 args = sys.argv[1:]435
18 unmodified lines