Flask CLI commands and arguments
Asked Answered
C

1

9

How do you let a Flask CLI command accept an argument?

Flask seems to customise the Click Group object, so this doesn't work:

@app.cli.command()
@app.cli.argument('email')
def user_info(email):
    ...
Corvine answered 23/6, 2017 at 12:44 Comment(0)
H
21

@app.cli.command is only to tell the click about this user_info. If you want the arguments and other click functionality please use click as well.

@app.cli.command()
@click.option('--email')
def user_info(email):
    ...
Habitancy answered 23/6, 2017 at 13:0 Comment(1)
import click # Click is a simple Python module inspired by the stdlib optparse to make writing command line scripts fun. Unlike other modules, it's based around a simple API that does not come with too much magic and is composable.Leupold

© 2022 - 2024 — McMap. All rights reserved.