Пример #1
0
    def init_app(self, app):
        group = click.Group(name='user',
                            help='Scripts to administrate user accounts.')

        options = self.__get_options()
        group.add_command(
            click.Command(
                name='create',
                callback=with_appcontext(self.create_user),
                params=[options['name'], options['password']],
                help='Create a new user. Name and password required.',
            ))
        group.add_command(
            click.Command(
                name='list',
                callback=with_appcontext(self.list_users),
                help='List info of users',
            ))
        group.add_command(
            click.Command(name='update',
                          callback=with_appcontext(self.update_user),
                          params=[
                              options['name'], options['password'],
                              options['status']
                          ],
                          help='Update status and/or password of a user.'))
        app.cli.add_command(group)
Пример #2
0
def _setup_cli():
    for command in flask_migrate_cli.commands.itervalues():
        if command.name == 'init':
            continue
        command.callback = partial(with_appcontext(_call_with_plugins), _func=command.callback)
        if command.name == 'downgrade':
            command.callback = partial(with_appcontext(_safe_downgrade), _func=command.callback)
        cli.add_command(command)
Пример #3
0
def _setup_cli():
    for command in flask_migrate_cli.commands.itervalues():
        if command.name == 'init':
            continue
        command.callback = partial(with_appcontext(_call_with_plugins), _func=command.callback)
        if command.name == 'downgrade':
            command.callback = partial(with_appcontext(_safe_downgrade), _func=command.callback)
        cli.add_command(command)
Пример #4
0
    def configure_commands(self):
        from flask.cli import with_appcontext
        from .commands import routes

        # add_command does not wrap command with context
        # so, we have to register it in a different way
        self.cli.add_command(with_appcontext(routes), 'routes')
Пример #5
0
def common_options(f):
    f = click.option(
        "--suppress",
        "verbose",
        flag_value=False,
        default=True,
        help="Do not show verbose outputs.",
    )(f)
    return with_appcontext(f)
Пример #6
0
    def init_app(self, app):
        group = click.Group(name='db_migration',
                            help='Scripts to alter DB schema.')

        group.add_command(
            click.Command(name='init',
                          callback=with_appcontext(self.init_migrations),
                          help='Creates a table to follow migrations.'))

        group.add_command(
            click.Command(
                name='check',
                callback=with_appcontext(self.check_migrations),
                help='Verifies if DB schema is sync with migration files.'))

        group.add_command(
            click.Command(name='apply',
                          callback=with_appcontext(self.apply_migrations),
                          help='Updates DB schema.'))

        app.cli.add_command(group)
Пример #7
0
 def decorator(f):
     if wrap_for_ctx:
         f = with_appcontext(f)
     return DefaultGroup.command(self, *args, **kwargs)(f)
Пример #8
0
 def decorator(f):
     cmd = click.command(*args, **kwargs)(with_appcontext(f))
     _commands.append(cmd)
     return cmd
Пример #9
0
 def decorated(*args, **kwargs):
     try:
         load_dotenv('.flaskenv')
         return with_appcontext(f)(*args, **kwargs)
     except:
         return f(*args, **kwargs)