karec / cookiecutter-flask-restful

Flask cookiecutter template for builing APIs with flask-restful, including JWT auth, cli, tests, swagger, docker and more

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

add cli elements to flask terminal command

DonalChilde opened this issue · comments

It would be useful to add the cli commands (manage.cli) to the flask terminal command. This is a change of just a few lines, and would provide easy access to cli actions. e.g.

flask app init

where app is declared as the top level group for commands related to the.... app.

Doing it this way also makes it easy to access current_app inside commands.

I imagine a blueprint that contains the app click.group which can be imported to all other modules with cli commands and used as the top level namespace for commands specific to the app.

I have a working general example at https://github.com/DonalChilde/flask_cli -> manual_cli branch

I would be happy to try to submit a pull request if you are interested in the idea, but I've never done that before so it would take some time to figure it out.

Hello @DonalChilde,

This would be indeed a good idea ! I've used the plugin way to add command (https://flask.palletsprojects.com/en/1.1.x/cli/#plugins) but I agree that it would be easier to add a group to flask CLI directly.

I would be happy to review a pull request if you want to give it a try, and don't worry I'm not sure I will have the time to work on this anytime soon, so take the time you need.