def _arguments(): """Return CLI arguments.""" arguments_dict = { 'optional_args': { 'local_path': { 'commands': ['--local-path'], 'help': 'Local path to cloned code.', 'metavar': '[PATH]', 'required': True }, 'report_file': { 'commands': ['--report-file'], 'help': 'Full path to write the package report to', 'metavar': '[FILE_PATH]', 'required': True }, 'storage_pool': { 'commands': ['--storage-pool'], 'help': 'Full path to the directory where you want to store' ' built wheels.', 'metavar': '[PATH]', 'required': True }, 'release_directory': { 'commands': ['--release-directory'], 'help': 'Full path to the directory where the releaesed links' ' will be stored.', 'metavar': '[PATH]', 'required': True }, 'add_on_repos': { 'commands': ['--add-on-repos'], 'help': 'Full repo path to require as an additional add on' ' repo. Example:' ' "git+https://github.com/rcbops/other-repo@master"', 'metavar': '[REPO_NAME]', 'nargs': '+' }, 'link_pool': { 'commands': ['--link-pool'], 'help': 'Full path to the directory links are stored.', 'metavar': '[PATH]', 'required': True } } } return arguments.ArgumentParserator( arguments_dict=arguments_dict, epilog='Licensed Apache2', title='Discover all of the requirements within the' ' os-ansible-deployment project.', detail='Requirement lookup', description='Discover all of the requirements within the' ' os-ansible-deployment project.', env_name='OS_ANSIBLE').arg_parser()
def _arguments(): """Return CLI arguments.""" return arguments.ArgumentParserator( arguments_dict=yaprt.ARGUMENTS_DICT, epilog='Licensed Apache2', title='Python package builder Licensed "Apache 2.0"', detail='Openstack package builder', description='Openstack, Python wheel builder', env_name='OS_REPO').arg_parser()
def test_class_variables(self): self.arguments = arguments.ArgumentParserator( arguments_dict=self.args, env_name='test_args', epilog='epilog', title='title', detail='detail', description='description' ) self.assertEqual(self.arguments.usage, '%(prog)s') self.assertEqual(self.arguments.env_name, 'test_args') self.assertEqual(self.arguments.epilog, 'epilog') self.assertEqual(self.arguments.title, 'title') self.assertEqual(self.arguments.detail, 'detail') self.assertEqual(self.arguments.description, 'description')
def execute(): """This is the run section of the application Turbolift.""" if len(sys.argv) <= 1: raise SystemExit( 'No Arguments provided. use [--help] for more information.') # Capture user arguments _args = arguments.ArgumentParserator( arguments_dict=turbolift.ARGUMENTS, env_name='TURBO', epilog=turbolift.VINFO, title='Turbolift', detail='Multiprocessing Swift CLI tool.', description='Manage Swift easily and fast.') user_args = _args.arg_parser() user_args['run_indicator'] = True debug_log = False stream_logs = True # Load system logging if user_args.get('debug'): debug_log = True user_args['run_indicator'] = False # Load system logging if user_args.get('quiet'): stream_logs = False user_args['run_indicator'] = False _logging = logger.LogSetup(debug_logging=debug_log, colorized_messages=user_args.get( 'colorized', False)) _logging.default_logger(name='turbolift', enable_stream=stream_logs) job = worker.Worker(job_args=user_args) job.run_manager()
def setUp(self): self.sys_argv_original = arguments.argparse._sys.argv self.sys_argv = arguments.argparse._sys.argv = [] self.print_patched = mock.patch( 'cloudlib.arguments.argparse._sys.stderr' ) self.mock_open = self.print_patched.start() self.args = { 'optional_args': { 'base_option1': { 'commands': ['--base-option1'], 'help': 'Helpful Information' } }, 'positional_args': { 'possitional1': { 'help': 'Helpful Information', } }, 'subparsed_args': { 'subparsed1': { 'help': 'Helpful Information', 'optional_args': { 'groups': { 'some_group_name': { 'text': 'other information', 'group': [ 'other_option3' ] } }, 'mutually_exclusive': { 'some_name': { 'text': 'some information', 'required': False, 'group': [ 'option1', 'option2' ] } }, 'option1': { 'commands': ['--option1'], 'default': False, 'action': 'store_true', 'help': 'Helpful Information' }, 'option2': { 'commands': ['--option2'], 'default': False, 'action': 'store_true', 'help': 'Helpful Information' }, 'other_option3': { 'commands': ['--other-option3', '-O'], 'metavar': '[STRING]', 'type': str, 'help': 'Helpful Information' } } } } } self.arguments = arguments.ArgumentParserator( arguments_dict=self.args, env_name='test_args', epilog='epilog', title='title', detail='detail', description='description' )
def _arguments(): """Return CLI arguments.""" arguments_dict = { 'shared_args': { 'filter': { 'commands': [ '--filter' ], 'help': 'filter the git api repo returns to the string' ' type that begins with the string provided.' ' Filtering is ONLY ever used with pulling' ' from the upstream github API.' ' Default: %(default)s', 'metavar': '[STR]', 'default': 'openstack_role-' } }, 'optional_args': { 'requirement_file': { 'commands': [ '--requirement-file' ], 'help': 'Path to a dictionary file. The file should contain' ' one word per line. Default: %(default)s', 'metavar': '[PATH]', 'default': os.path.join( os.getcwd(), 'ansible-role-requirements.yml' ) }, 'repo': { 'commands': [ '--repo' ], 'help': 'Full path the git repo api path that the script will' ' scan through.', 'metavar': '[URL]', 'default': 'https://api.github.com/orgs/os-cloud/repos' }, 'git_username': { 'commands': [ '-u', '--git-username' ], 'help': 'Username for a github account.', 'metavar': '[STR]', 'default': None }, 'git_password': { 'commands': [ '-p', '--git-password' ], 'help': 'Passowrd for a github account.', 'metavar': '[STR]', 'default': None } }, 'subparsed_args': { 'update': { 'help': 'Run an update on an existing inventory. This will' ' attempt to update all of your role, that have a' ' defined `github_api` key to the latest tag. If a tag' ' is not available the default branch will be used.', 'shared_args': ['filter'] }, 'create': { 'help': 'Create a new ansible requirements file based on the' ' discovered repositories using a defined filter on' ' the repo name.', 'shared_args': ['filter'] } } } return arguments.ArgumentParserator( arguments_dict=arguments_dict, epilog='Licensed Apache2', title='Create/Update an ansible galaxy repository file', detail='Ansible Galaxy repository generator that will parse an' ' existing requirements file and update it the latest stable' ' release or create a new one if one was not passed into the' ' generator or discovered.', description='Generate an ansible galaxy requirements file.', env_name='OpenStack' ).arg_parser()
'commands': ['--option1'], 'default': False, 'action': 'store_true', 'help': 'Helpful Information' }, 'option2': { 'commands': ['--option2'], 'default': False, 'action': 'store_true', 'help': 'Helpful Information' }, 'other_option3': { 'commands': ['--other-option3', '-O'], 'metavar': '[STRING]', 'type': str, 'help': 'Helpful Information' } } } } } a = arguments.ArgumentParserator(arguments_dict=args, epilog='testing epilog', title='testing title', detail='testing detail', description='testing description') print a.arg_parser() import sys print sys.argv