quart.cli module#

class quart.cli.AppGroup(name: Optional[str] = None, commands: Optional[Union[Dict[str, Command], Sequence[Command]]] = None, **attrs: Any)#

Bases: Group

This works similar to a regular click Group but it changes the behavior of the command() decorator so that it automatically wraps the functions in with_appcontext().

Not to be confused with QuartGroup.

command(*args: Any, **kwargs: Any) Callable#

This works exactly like the method of the same name on a regular click.Group but it wraps callbacks in with_appcontext() if it’s enabled by passing with_appcontext=True.

group(*args: Any, **kwargs: Any) Callable#

A shortcut decorator for declaring and attaching a group to the group. This takes the same arguments as group() and immediately registers the created group with this group by calling add_command().

To customize the group class used, set the group_class attribute.

Changed in version 8.1: This decorator can be applied without parentheses.

Changed in version 8.0: Added the group_class attribute.

exception quart.cli.NoAppException#

Bases: UsageError

class quart.cli.QuartGroup(add_default_commands: bool = True, create_app: Optional[Callable] = None, add_version_option: bool = True, *, params: Optional[List] = None, **kwargs: Any)#

Bases: AppGroup

get_command(ctx: Context, name: str) Command#

Return the relevant command given the context and name.


This differs substantially from Flask in that it allows for the inbuilt commands to be overridden.

list_commands(ctx: Context) List[str]#

Returns a list of subcommand names in the order they should appear.

main(*args: Any, **kwargs: Any) Any#

This is the way to invoke a script with all the bells and whistles as a command line application. This will always terminate the application after a call. If this is not wanted, SystemExit needs to be caught.

This method is also available by directly calling the instance of a Command.

  • args – the arguments that should be used for parsing. If not provided, sys.argv[1:] is used.

  • prog_name – the program name that should be used. By default the program name is constructed by taking the file name from sys.argv[0].

  • complete_var – the environment variable that controls the bash completion support. The default is "_<prog_name>_COMPLETE" with prog_name in uppercase.

  • standalone_mode – the default behavior is to invoke the script in standalone mode. Click will then handle exceptions and convert them into error messages and the function will never return but shut down the interpreter. If this is set to False they will be propagated to the caller and the return value of this function is the return value of invoke().

  • windows_expand_args – Expand glob patterns, user dir, and env vars in command line args on Windows.

  • extra – extra keyword arguments are forwarded to the context constructor. See Context for more information.

Changed in version 8.0.1: Added the windows_expand_args parameter to allow disabling command line arg expansion on Windows.

Changed in version 8.0: When taking arguments from sys.argv on Windows, glob patterns, user dir, and env vars are expanded.

Changed in version 3.0: Added the standalone_mode parameter.

class quart.cli.ScriptInfo(app_import_path: Optional[str] = None, create_app: Optional[Callable] = None)#

Bases: object

load_app() Quart#
load_dotenv_if_exists() None#
quart.cli.get_version(ctx: Any, param: Any, value: Any) None#
quart.cli.main(as_module: bool = False) None#
quart.cli.with_appcontext(fn: Optional[Callable] = None) Callable#