def cli(context):
    if not get_key_netrc():
        context.fail('Key not found in netrc file')
    error_msg = remove_sh_key(NETRC_FILE)
    if error_msg:
        context.fail(error_msg)
    if get_key_netrc():
        context.fail(
            'Error removing key from the netrc file.'
            'Please, open the file ~/.netrc and remove it manually')
Beispiel #2
0
def cli(context):
    if auth.get_key_netrc():
        click.echo("You're already logged in. To change credentials, use 'shub logout' first.")
        return 0

    cfg_key = _find_cfg_key()
    key = _get_apikey(suggestion=cfg_key)
    auth.write_key_netrc(key)
Beispiel #3
0
def cli(context):
    if auth.get_key_netrc():
        log("You're already logged in. To change credentials, use 'shub logout' first.")
        return 0

    cfg_key = _find_cfg_key()
    key = _prompt_for_key(suggestion=cfg_key)

    if not key and is_valid_key(cfg_key):
        auth.write_key_netrc(cfg_key)
    elif key and is_valid_key(key):
        auth.write_key_netrc(key)
    else:
        context.fail('Invalid key. Tip: your key must have 32 characters.')
    log('Success.')