

@cli_app.command('create-admin')
@click.option('--app', default='app', help='Your application init directory (package)')
@click.option('--appbuilder', default='appbuilder', help='your AppBuilder object')
@click.option('--username', default='admin', prompt='Username')
@click.option('--firstname', default='admin', prompt='User first name')
@click.option('--lastname', default='user', prompt='User last name')
@click.option('--email', default='admin@fab.org', prompt='Email')
@click.password_option()
def create_admin(app, appbuilder, username, firstname, lastname, email, password):
    '\n        Creates an admin user\n    '
    auth_type = {
        c.AUTH_DB: 'Database Authentications',
        c.AUTH_OID: 'OpenID Authentication',
        c.AUTH_LDAP: 'LDAP Authentication',
        c.AUTH_REMOTE_USER: 'WebServer REMOTE_USER Authentication',
        c.AUTH_OAUTH: 'OAuth Authentication',
    }
    _appbuilder = import_application(app, appbuilder)
    click.echo(click.style('Recognized {0}.'.format(auth_type.get(_appbuilder.sm.auth_type, 'No Auth method')), fg='green'))
    role_admin = _appbuilder.sm.find_role(_appbuilder.sm.auth_role_admin)
    user = _appbuilder.sm.add_user(username, firstname, lastname, email, role_admin, password)
    if user:
        click.echo(click.style('Admin User {0} created.'.format(username), fg='green'))
    else:
        click.echo(click.style('No user created an error occured', fg='red'))

dataset/ETHPy150Open dpgaspar/Flask-AppBuilder/flask_appbuilder/console.py create_admin/original