Skip to content

CLI: "flask" command help doesn't list custom commands #1124

Closed

Description

@erwagasore

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?

Activity

  1. SherMM commented on Jul 17, 2014

    @SherMM

    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'

  2. erwagasore commented on Jul 17, 2014

    @erwagasore
    Author

    I learned alot from the image tweeted by @mitsuhiko how this will help @SherMM http://i.imgur.com/hhuKBkv.png

  3. SherMM commented on Jul 17, 2014

    @SherMM

    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.

  4. untitaker commented on Jul 17, 2014

    @untitaker
    Contributor

    There is no flask command. Where are you getting this information from?

  5. SherMM commented on Jul 18, 2014

    @SherMM

    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.

  6. erwagasore commented on Jul 18, 2014

    @erwagasore
    Author

    The cli.py module is in the latest flask commit on this repository. Check this out smurfix/flask-script#97 for more info on the future of flask

  7. untitaker commented on Aug 28, 2014

    @untitaker
    Contributor

    Sorry for closing.

  8. changed the title [-]Calling "flask" command doesn't show my custom commands near "run" and "shell"[/-] [+]"flask" command help doesn't list custom commands[/+] on Aug 28, 2014
  9. changed the title [-]"flask" command help doesn't list custom commands[/-] [+]CLI: "flask" command help doesn't list custom commands[/+] on Aug 28, 2014
  10. untitaker commented on Aug 28, 2014

    @untitaker
    Contributor

    Since flask --help works correctly i suppose that this is a deficiency in click.

  11. pbu88 commented on Aug 29, 2014

    @pbu88

    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.

  12. untitaker commented on Aug 29, 2014

    @untitaker
    Contributor

    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.

  13. added this to the 1.0 milestone on Oct 20, 2014
  14. added a commit that references this issue on Apr 18, 2015
    154bc18
  15. mitsuhiko commented on May 26, 2016

    @mitsuhiko
    Contributor

    I'm closing this for now as the latest changes implicitly fixed this.

  16. locked as resolved and limited conversation to collaborators on Nov 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions