I am playing with the latest release of flask with cli module. I have created a command called initdb and when I call flask initdb it works as expected, but when I just call flask command it supposed to show the list of all available commands including initdb, which is not the case. Any idea why?
The flask command doesn't work for me. I don't know if I haven't set something up incorrectly, but trying to follow examples where the flask command is used do not work for me. I get the following:
flask: command not found. Also, when trying to play with the minitwit example, and just trying python minitwit.py or python minitwit_tests.py I get the following error: @app.cli.command('initdb')
AttributeError: 'Flask' object has no attribute 'cli'
I learned alot from the image tweeted by @mitsuhiko how this will help @SherMM http://i.imgur.com/hhuKBkv.png
I still cannot get the flask command to work, even after following post by @erwagasore . I haven't used Flask in a couple months, but my version is current. I am not sure if there needs to be a flask_config file or something else, but no shell I use recognizes this command.
There is no flask command. Where are you getting this information from?
This is just what I interpreted (apparently incorrectly) from the minitwit docs and link provided by @erwagasore above. I just realized, I don't have the version of flask with the cli.py module. So, I am guess it's my problem. Sorry for the confusion, but thanks for the help anyways.
The cli.py module is in the latest flask commit on this repository. Check this out https://github.com/smurfix/flask-script/issues/97 for more info on the future of flask
Sorry for closing.
Since flask --help works correctly i suppose that this is a deficiency in click.
I think I got a clue on this one. It seems indeed a problem with click. The envvar access is actually never executed:
# click.core.MultiCommand.parse_args
def parse_args(self, ctx, args):
if not args and self.no_args_is_help and not ctx.resilient_parsing:
echo(ctx.get_help())
ctx.exit()
return Command.parse_args(self, ctx, args)
This is the closest I've come to narrow the problem. If not args (flask) the function will exit on ctx.exit() but the problem is that env variables are actually accessed in Command.parse_args. That's why flask --help works correctly, because it has at least one arg and the environment gets set up.
I've also come that far. As a workaround we could set invoke_without_subcommand to true and print the help manually, but i think this should be fixed in click.
I'm closing this for now as the latest changes implicitly fixed this.
Most helpful comment
I'm closing this for now as the latest changes implicitly fixed this.