Use the short_help
parameter. AppGroup
inherits from Group
which inherits from MultiCommand
which inherits from Command
. See Click source code for Command
.
For example:
import click
from flask import Flask
from flask.cli import AppGroup
user_cli = AppGroup('user', short_help="Adds a user")
@user_cli.command('create')
@click.argument('name')
def create_user(name):
print(name)
app = Flask(__name__)
app.cli.add_command(user_cli)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run()
Gives the following output (Windows PyCharm terminal):
(flask_cli_group) D:\Paul\PycharmProjects\flask_cli_group>flask
Usage: flask [OPTIONS] COMMAND [ARGS]...
A general utility script for Flask applications.
Provides commands from Flask, extensions, and the application. Loads the
application defined in the FLASK_APP environment variable, or from a
wsgi.py file. Setting the FLASK_ENV environment variable to 'development'
will enable debug mode.
> set FLASK_APP=hello.py
> set FLASK_ENV=development
> flask run
Options:
--version Show the flask version
--help Show this message and exit.
Commands:
routes Show the routes for the app.
run Run a development server.
shell Run a shell in the app context.
user Adds a user
(flask_cli_group) D:\Paul\PycharmProjects\flask_cli_group>