

@click.command()
@click.option('--get', '-g', 'action', flag_value='get_credential', help='retrieve a credential from keyring storage')
@click.option('--set', '-s', 'action', flag_value='set_credential', help='store a credential in keyring storage')
@click.argument('environment', nargs=1)
@click.argument('parameter', nargs=1)
@click.pass_context
def run_supernova_keyring(ctx, action, environment, parameter):
    "\n    Sets or retrieves credentials stored in your system's keyring using the\n    python-keyring module.\n\n    Global credentials can be shared between multiple configuration sections:\n\n    \x08\n        [prod]\n        OS_PASSWORD=USE_KEYRING['sso_password']\n        ...\n\n    \x08\n        [staging]\n        OS_PASSWORD=USE_KEYRING['my sso_password']\n        ...\n\n    You could retrieve or set the global credential using these commands:\n\n    \x08\n        supernova -g global sso_password     <= get the credential\n        supernova -s global sso_password     <= set the credential\n\n    Local credentials are intended for use with only one configuration section:\n\n    \x08\n        [prod]\n        OS_PASSWORD=USE_KEYRING\n        ...\n\n    \x08\n        [staging]\n        OS_PASSWORD=USE_KEYRING\n        ...\n\n    You could retrieve or set the local credential using these commands:\n\n    \x08\n        supernova -g prod OS_PASSWORD     <= get the credential for prod\n        supernova -s prod OS_PASSWORD     <= set the credential for prod\n\n    \x08\n        supernova -g staging OS_PASSWORD  <= get the credential for staging\n        supernova -s staging OS_PASSWORD  <= set the credential for staging\n\n    Full documentation:\n\n    \x08\n        http://supernova.readthedocs.org/en/latest/configuring/\n\n    "
    if (action == 'get_credential'):
        result = credentials.get_user_password(env=environment, param=parameter)
        if (not result):
            click.echo('\nUnable to find a credential matching the data provided.')
            ctx.exit(1)
        else:
            click.echo('\nFound credential for {0}: {1}'.format(*result))
            ctx.exit()
    elif (action == 'set_credential'):
        msg = '\nPreparing to set a credential in the keyring for:\n\n  - Environment  : {0}\n  - Parameter    : {1}\n\nIf this is correct, enter the corresponding credential to store in your keyring\nor press CTRL-C to abort'.format(environment, parameter)
        credential = click.prompt(text=msg, hide_input=True)
        result = credentials.set_user_password(environment=environment, parameter=parameter, password=credential)
        if result:
            click.echo('\nSuccessfully stored.')
            ctx.exit()
        else:
            click.echo('\nUnable to store your credential.')
            ctx.exit(1)
    else:
        click.secho('ERROR: must specify --get or --set', bold=True)
        click.echo(ctx.get_help())
        ctx.exit()

dataset/ETHPy150Open major/supernova/supernova/executable.py run_supernova_keyring/original