New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Blueprint level cli registration-- #1357 #2784

Open
wants to merge 4 commits into
base: master
from

Conversation

Projects
None yet
2 participants
@doobeh
Contributor

doobeh commented May 15, 2018

So, this tries to address the ability to easily add commands to blueprints, and let them get stacked into the applications cli group in one of three ways.

The default is nested, with name taken from the bp name, giving you flask user create:

bp = Blueprint('user', __name__)
bp.cli.command('create')

Optionally you can override that grouping name, giving you flask librarian create:

bp = Blueprint('user', __name__, cli_group='librarian')
bp.cli.command('create')

Or, you can specify None as the group, which applies it directly to the root app's cli group giving flask add_user:

bp = Blueprint('user', __name__, cli_group=None)
bp.cli.command('add_user')

The tests show each of these options. Let me know your thoughts and I'll add the documentation changes required if everyone think's it's useful to proceed.

cli_group can also be specified when registering on the app: app.register_blueprint(bp, cli_group="librarian") to override the bp level cli_group choice.

@ThiefMaster

This comment has been minimized.

Member

ThiefMaster commented May 15, 2018

Please keep the first line of your commit messages shorter than 51 chars (see https://chris.beams.io/posts/git-commit/)

doobeh added some commits May 15, 2018

Add Blueprint level cli command registration
Implements #1357.
Adds ability to register click cli commands onto blueprint.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment