Browse Source

Merge pull request #2359 from davidism/cli-warning

Be smarter about adding ".cli" to reloader command
pull/2360/head
David Lord 8 years ago committed by GitHub
parent
commit
f29fa0d56b
  1. 16
      flask/cli.py

16
flask/cli.py

@ -647,19 +647,19 @@ Example usage:
def main(as_module=False): def main(as_module=False):
this_module = __package__ + '.cli'
args = sys.argv[1:] args = sys.argv[1:]
if as_module: if as_module:
if sys.version_info >= (2, 7): this_module = 'flask'
name = 'python -m ' + this_module.rsplit('.', 1)[0]
else: if sys.version_info < (2, 7):
this_module += '.cli'
name = 'python -m ' + this_module name = 'python -m ' + this_module
# This module is always executed as "python -m flask.run" and as such # Python rewrites "python -m flask" to the path to the file in argv.
# we need to ensure that we restore the actual command line so that # Restore the original command so that the reloader works.
# the reloader can properly operate. sys.argv = ['-m', this_module] + args
sys.argv = ['-m', this_module] + sys.argv[1:]
else: else:
name = None name = None

Loading…
Cancel
Save