def cmd_login(_, __): """Performs ``nexus3 login``""" nexus_url = util.input_with_default('Nexus OSS URL', nexus_config.DEFAULTS['url']) nexus_user = util.input_with_default('Nexus admin username', nexus_config.DEFAULTS['username']) nexus_pass = getpass.getpass( prompt=f'Nexus admin password ({nexus_config.DEFAULTS["password"]}):') if not nexus_pass: nexus_pass = nexus_config.DEFAULTS['password'] nexus_verify = _input_yesno('Verify server certificate', nexus_config.DEFAULTS['x509_verify']) config = nexus_config.NexusConfig(username=nexus_user, password=nexus_pass, url=nexus_url, x509_verify=nexus_verify) # make sure configuration works before saving NexusClient(config=config) config.dump() sys.stderr.write(f'\nConfiguration saved to {config.config_file}\n')
def cmd_delete(nexus_client, args): """Performs ``nexus3 repository delete``""" if not args.get('--force'): util.input_with_default('Press ENTER to confirm deletion', 'ctrl+c to cancel') nexus_client.repositories.delete(args.get('<repo_name>')) return errors.CliReturnCode.SUCCESS.value
def _input_yesno(prompt, default): """ Prompts for a yes/true/no/false answer. :param prompt: question to be displayed to user :param default: default choice, also used for invalid answers :return: choice :rtype: bool """ try: return YESNO_OPTIONS[util.input_with_default(prompt, default).lower()] except KeyError: return default