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
Closed

Support for @blueprint.cli.command #1357

lnielsen opened this issue Feb 20, 2015 · 3 comments

Comments

@lnielsen
Copy link

@lnielsen lnielsen 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
Copy link
Member

@ThiefMaster ThiefMaster 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.

Loading

@lnielsen
Copy link
Author

@lnielsen lnielsen 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.

Loading

@rsyring
Copy link
Contributor

@rsyring rsyring 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.

Loading

@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
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
Implements pallets#1357.
Adds ability to register click cli commands onto blueprint.
davidism added a commit that referenced this issue May 24, 2019
Add Blueprint level cli registration-- #1357
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

5 participants