

def add_configuration(options):
    '\n    interactively add a new configuration\n\n    '
    if (options.username != None):
        username = options.username
    else:
        username = prompt('Username: ')
    if (options.password != None):
        password = options.password
    else:
        password = prompt('Password: ', hide_input=(not options.show_password))
    if (options.app_url != None):
        app_url = options.app_url
    else:
        app_url = prompt('App URL (default: https://app.jut.io just hit enter): ')
    if (app_url.strip() == ''):
        app_url = 'https://app.jut.io'
    section = ('%s@%s' % (username, app_url))
    if config.exists(section):
        raise JutException(('Configuration for "%s" already exists' % section))
    token_manager = auth.TokenManager(username=username, password=password, app_url=app_url)
    authorization = authorizations.get_authorization(token_manager, app_url=app_url)
    client_id = authorization['client_id']
    client_secret = authorization['client_secret']
    deployment_name = default_deployment(app_url, client_id, client_secret)
    config.add(section, **{
        'app_url': app_url,
        'deployment_name': deployment_name,
        'username': username,
        'client_id': client_id,
        'client_secret': client_secret,
    })
    if options.default:
        config.set_default(name=section)
    else:
        default_configuration(interactive=False)

dataset/ETHPy150Open jut-io/jut-python-tools/jut/commands/configs.py add_configuration/original