Skip to content
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

Support for @blueprint.cli.command #1357

Closed
lnielsen opened this issue Feb 20, 2015 · 3 comments

Comments

@lnielsen
Copy link

commented Feb 20, 2015

It would be great to have access to the functionality of app.cli.command via blueprints - i.e. something like:

blueprint = Blueprint('myblueprint', __name__,)

@blueprint.cli.command()
def doblueprintstuff():
    """Initialize the database."""
    #....

It would help a lot when building modular applications.

@ThiefMaster

This comment has been minimized.

Copy link
Member

commented Feb 20, 2015

Sounds like a useful feature. The question is.. would the command become a direct subcommand of flask such as flask doblueprintstuff or be somehow separated, e.g. flask myblueprint doblueprintstuff. I could imagine arguments for both cases depending on the applications.

Maybe blueprint.cli.command and blueprint.app_cli.command similar to how blueprints can modify some things (e.g. error handlers) either globally for the whole app or just for the blueprint.

@lnielsen

This comment has been minimized.

Copy link
Author

commented Feb 20, 2015

Maybe blueprint.cli.command and blueprint.app_cli.command similar to how blueprints can modify some things (e.g. error handlers) either globally for the whole app or just for the blueprint.

Yep, I can see valid uses cases for both as well, so I think blueprint.cli.command and blueprint.app_cli.command is a nice way to not force a particular scheme upon developers.

@rsyring

This comment has been minimized.

Copy link
Contributor

commented May 18, 2015

Having both blueprint.app_cli and blueprint.cli seems not ideal to me. Also, you should have a way to specific the subcommand group a command falls under. Default that to the blueprint name, but allow an override.

Other options:

blueprint = Blueprint('myblueprint', __name__, cli_group_name='blue')

@blueprint.cli.command()
def doblueprintstuff():
    """Initialize the database."""
    #....

Command would need to be run as myapp blue doblueprintstuff.

blueprint = Blueprint('myblueprint', __name__, cli_group_name='blue')

@blueprint.cli.command(on_app=True)
def doblueprintstuff():
    """Initialize the database."""
    #....

Called as: myapp doblueprintstuff.

@davidism davidism added the cli label May 29, 2017

doobeh added a commit to doobeh/flask that referenced this issue May 15, 2018

doobeh added a commit to doobeh/flask that referenced this issue May 15, 2018

Add Blueprint level cli command registration
Implements pallets#1357.
Adds ability to register click cli commands onto blueprint.

@davidism davidism added this to the 1.1.0 milestone May 24, 2019

davidism added a commit to doobeh/flask that referenced this issue May 24, 2019

Add Blueprint level cli command registration
Implements pallets#1357.
Adds ability to register click cli commands onto blueprint.

davidism added a commit that referenced this issue May 24, 2019

Merge pull request #2784 from doobeh/master
Add Blueprint level cli registration-- #1357
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.