Skip to content

Instantly share code, notes, and snippets.

@jezdez
Created April 28, 2016 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jezdez/5eed32e686bf69e89325e99d073646da to your computer and use it in GitHub Desktop.
Save jezdez/5eed32e686bf69e89325e99d073646da to your computer and use it in GitHub Desktop.
Patch Click to use a Flask 1.0 AppGroup by default to get automatic app context for commands
import click
try:
from flask.cli import AppGroup
except ImportError:
from flask_cli import AppGroup
def group(name=None, **attrs):
"""The same as ``click.grop`` but sets the default command class
to ``flask.cli.AppGroup``
"""
attrs.setdefault('cls', AppGroup)
return click.command(name, **attrs)
click.group = group
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment