示例#1
0
def load_team_arguments(cli_command_loader):
    with ArgumentsContext(cli_command_loader, 'login') as ac:
        ac.argument('team_instance', options_list=('--instance', '-i'))
        ac.argument('detect', **enum_choice_list(_ON_OFF_SWITCH_VALUES))
    with ArgumentsContext(cli_command_loader, 'logout') as ac:
        ac.argument('team_instance', options_list=('--instance', '-i'))
        ac.argument('detect', **enum_choice_list(_ON_OFF_SWITCH_VALUES))
    with ArgumentsContext(cli_command_loader, 'configure') as ac:
        ac.argument('defaults', options_list=('--defaults', '-d'), nargs='*')
    with ArgumentsContext(cli_command_loader, 'project') as ac:
        ac.argument('team_instance', options_list=('--instance', '-i'))
        ac.argument('process', options_list=('--process', '-p'))
        ac.argument('source_control',
                    options_list=('--source-control', '-s'),
                    **enum_choice_list(_SOURCE_CONTROL_VALUES))
        ac.argument('description', options_list=('--description', '-d'))
        ac.argument('detect', **enum_choice_list(_ON_OFF_SWITCH_VALUES))
        ac.argument('state', **enum_choice_list(_STATE_VALUES))
        ac.argument('project_id', options_list='--id')
    with ArgumentsContext(cli_command_loader, 'configure') as ac:
        ac.argument('collect_telemetry',
                    **enum_choice_list(_YES_NO_SWITCH_VALUES))
        ac.argument('enable_log_file',
                    **enum_choice_list(_YES_NO_SWITCH_VALUES))
        ac.argument('use_git_aliases',
                    **enum_choice_list(_YES_NO_SWITCH_VALUES))
        ac.argument('suppress_update_message',
                    **enum_choice_list(_YES_NO_SWITCH_VALUES))
        ac.argument('default_output', **enum_choice_list(_OUTPUT_VALUES))
        ac.argument('list_config', options_list=('--list', '-l'))
def load_build_arguments(self, _):
    with self.argument_context('pipelines build list') as context:
        context.argument('definition_ids', nargs='*', type=int)
        context.argument('tags', nargs='*')
        context.argument('reason', **enum_choice_list(_BUILD_REASON_VALUES))
        context.argument('result', **enum_choice_list(_BUILD_RESULT_VALUES))
        context.argument('status', **enum_choice_list(_BUILD_STATUS_VALUES))

    with self.argument_context('pipelines build queue') as context:
        context.argument('definition_id', type=int)
        context.argument('variables', nargs='*')

    with self.argument_context('pipelines build definition list') as context:
        context.argument('repository_type',
                         choices=[
                             'tfsversioncontrol', 'tfsgit', 'git', 'github',
                             'githubenterprise', 'bitbucket', 'svn'
                         ],
                         type=str.lower)

    with self.argument_context('pipelines release list') as context:
        context.argument('definition_id', type=int)

    with self.argument_context('pipelines release create') as context:
        context.argument('definition_id', type=int)
        context.argument('artifact_metadata_list', nargs='*')

    with self.argument_context('pipelines release definition list') as context:
        context.argument('artifact_type',
                         choices=[
                             'build', 'jenkins', 'github', 'externaltfsbuild',
                             'git', 'tfvc'
                         ],
                         type=str.lower)
示例#3
0
def load_admin_arguments(cli_command_loader):
    with ArgumentsContext(cli_command_loader, 'admin') as ac:
        ac.argument('team_instance', options_list=['-i', '--instance'])
    with ArgumentsContext(cli_command_loader, 'admin user') as ac:
        ac.argument('user_id', options_list='--id')
        ac.argument('access_level', **enum_choice_list(_ORGANIZATION_LICENSE_TYPES_FOR_ADD))
    with ArgumentsContext(cli_command_loader, 'admin banner') as ac:
        ac.argument('message', options_list=['-m', '--message'])
        ac.argument('message_id', options_list='--id')
        ac.argument('banner_type', options_list=['-t', '--type'], **enum_choice_list(_TYPE_FOR_BANNER))
示例#4
0
def load_admin_arguments(self, _):
    with self.argument_context('devops admin') as context:
        context.argument('organization',
                         options_list=['--org', '--organization'])
    with self.argument_context('devops admin user') as context:
        context.argument('user_id', options_list='--id')
        context.argument(
            'access_level',
            **enum_choice_list(_ORGANIZATION_LICENSE_TYPES_FOR_ADD))
    with self.argument_context('devops admin banner') as context:
        context.argument('message', options_list=['-m', '--message'])
        context.argument('banner_type',
                         options_list=['-t', '--type'],
                         **enum_choice_list(_TYPE_FOR_BANNER))
示例#5
0
    def test_case_insensitive_enum_choices(self):
        from enum import Enum

        class TestEnum(Enum):  # pylint: disable=too-few-public-methods

            opt1 = "ALL_CAPS"
            opt2 = "camelCase"
            opt3 = "snake_case"

        def test_handler():
            pass

        cli = TestCli()
        cli.loader = mock.MagicMock()
        cli.loader.cli_ctx = cli

        command = AzCliCommand(cli.loader, 'test command', test_handler)
        command.add_argument('opt', '--opt', required=True, **enum_choice_list(TestEnum))
        cmd_table = {'test command': command}
        cli.commands_loader.command_table = cmd_table

        parser = AzCliCommandParser(cli)
        parser.load_command_table(cli.commands_loader)

        args = parser.parse_args('test command --opt alL_cAps'.split())
        self.assertEqual(args.opt, 'ALL_CAPS')

        args = parser.parse_args('test command --opt CAMELCASE'.split())
        self.assertEqual(args.opt, 'camelCase')

        args = parser.parse_args('test command --opt sNake_CASE'.split())
        self.assertEqual(args.opt, 'snake_case')
示例#6
0
def load_build_arguments(cli_command_loader):
    with ArgumentsContext(cli_command_loader, 'build') as ac:
        ac.argument('open_browser', options_list='--open')
        ac.argument('project', options_list=('--project', '-p'))
        ac.argument('team_instance', options_list=('--instance', '-i'))
        ac.argument('detect', **enum_choice_list(_ON_OFF_SWITCH_VALUES))

    with ArgumentsContext(cli_command_loader, 'build list') as ac:
        ac.argument('definition_ids', nargs='*', type=int)
        ac.argument('tags', nargs='*')

    with ArgumentsContext(cli_command_loader, 'build queue') as ac:
        ac.argument('definition_id', type=int)
        ac.argument('variables', nargs='*')

    with ArgumentsContext(cli_command_loader, 'build show') as ac:
        ac.argument('build_id', options_list='--id', type=int)

    with ArgumentsContext(cli_command_loader, 'build definition show') as ac:
        ac.argument('definition_id', options_list='--id', type=int)

    with ArgumentsContext(cli_command_loader, 'build definition list') as ac:
        ac.argument('repository_type',
                    choices=[
                        'tfsversioncontrol', 'tfsgit', 'git', 'github',
                        'githubenterprise', 'bitbucket', 'svn'
                    ],
                    type=str.lower)

    with ArgumentsContext(cli_command_loader, 'build task') as ac:
        ac.argument('task_id', options_list='--id', type=str)
示例#7
0
    def test_case_insensitive_enum_choices(self):
        from enum import Enum

        class TestEnum(Enum):  # pylint: disable=too-few-public-methods

            opt1 = "ALL_CAPS"
            opt2 = "camelCase"
            opt3 = "snake_case"

        def test_handler():
            pass

        cli = DummyCli()
        cli.loader = mock.MagicMock()
        cli.loader.cli_ctx = cli

        command = AzCliCommand(cli.loader, 'test command', test_handler)
        command.add_argument('opt',
                             '--opt',
                             required=True,
                             **enum_choice_list(TestEnum))
        cmd_table = {'test command': command}
        cli.commands_loader.command_table = cmd_table

        parser = AzCliCommandParser(cli)
        parser.load_command_table(cli.commands_loader)

        args = parser.parse_args('test command --opt alL_cAps'.split())
        self.assertEqual(args.opt, 'ALL_CAPS')

        args = parser.parse_args('test command --opt CAMELCASE'.split())
        self.assertEqual(args.opt, 'camelCase')

        args = parser.parse_args('test command --opt sNake_CASE'.split())
        self.assertEqual(args.opt, 'snake_case')
def load_package_arguments(self, _):
    with self.argument_context('artifacts universal') as context:
        context.argument('name', options_list=('--name', '-n'))
        context.argument('version', options_list=('--version', '-v'))
        context.argument('scope', **enum_choice_list(_SCOPE_VALUES))
    with self.argument_context('artifacts universal publish') as context:
        context.argument('description', options_list=('--description', '-d'))
示例#9
0
def repo_policy_create_udpate_common_arguments(context):
    context.argument('policy_type', **enum_choice_list(REPO_POLICY_TYPE))
    context.argument('repository_id', options_list=('--repository-id', '-r'))
    APPROVER_COUNT_POLICY_ARGUMENT_GROUP = 'Approver Count Policy'
    context.argument('minimumApproverCount',
                     arg_group=APPROVER_COUNT_POLICY_ARGUMENT_GROUP)
    context.argument('creatorVoteCounts',
                     arg_group=APPROVER_COUNT_POLICY_ARGUMENT_GROUP)
    context.argument('allowDownvotes',
                     arg_group=APPROVER_COUNT_POLICY_ARGUMENT_GROUP)
    context.argument('resetOnSourcePush',
                     arg_group=APPROVER_COUNT_POLICY_ARGUMENT_GROUP)
    MERGE_STRATEGY_POLICY_ARGUMENT_GROUP = 'Merge Strategy Policy'
    context.argument('useSquashMerge',
                     arg_group=MERGE_STRATEGY_POLICY_ARGUMENT_GROUP)
    BUILD_POLICY_ARGUMENT_GROUP = 'Build Policy'
    context.argument('buildDefinitionId',
                     arg_group=BUILD_POLICY_ARGUMENT_GROUP)
    context.argument('queueOnSourceUpdateOnly',
                     arg_group=BUILD_POLICY_ARGUMENT_GROUP)
    context.argument('manualQueueOnly', arg_group=BUILD_POLICY_ARGUMENT_GROUP)
    context.argument('displayName', arg_group=BUILD_POLICY_ARGUMENT_GROUP)
    context.argument('validDuration', arg_group=BUILD_POLICY_ARGUMENT_GROUP)
    FILE_SIZE_POLICY_ARGUMENT_GROUP = 'File Size Policy'
    context.argument('maximumGitBlobSizeInBytes',
                     arg_group=FILE_SIZE_POLICY_ARGUMENT_GROUP)
    context.argument('useUncompressedSize',
                     arg_group=FILE_SIZE_POLICY_ARGUMENT_GROUP)
    REQUIRED_REVIEWER_POLICY_GROUP = 'Required Reviewer Policy'
    context.argument('optionalReviewerIds',
                     arg_group=REQUIRED_REVIEWER_POLICY_GROUP)
    context.argument('requiredReviewerIds',
                     arg_group=REQUIRED_REVIEWER_POLICY_GROUP)
    context.argument('message', arg_group=REQUIRED_REVIEWER_POLICY_GROUP)
示例#10
0
 def load_command_table(self, args):
     super(ExtCommandsLoader, self).load_command_table(args)
     command = AzCliCommand(loader, 'test extension', test_handler)
     command.add_argument('opt',
                          '--opt',
                          required=True,
                          **enum_choice_list(TestEnum))
     self.command_table['test extension'] = command
     return self.command_table
def load_package_arguments(self, _):
    with self.argument_context('artifacts universal') as context:
        context.argument('organization',
                         options_list=('--organization', '--org'))
        context.argument('detect', **enum_choice_list(_ON_OFF_SWITCH_VALUES))
        context.argument('name', options_list=('--name', '-n'))
        context.argument('version', options_list=('--version', '-v'))
    with self.argument_context('artifacts universal publish') as context:
        context.argument('description', options_list=('--description', '-d'))
示例#12
0
def load_code_arguments(cli_command_loader):
    with ArgumentsContext(cli_command_loader, 'code') as ac:
        ac.argument('open_browser', options_list='--open')
        ac.argument('project', options_list=('--project', '-p'))
        ac.argument('team_instance', options_list=('--instance', '-i'))
        ac.argument('reviewers', nargs='*')
        ac.argument('detect', **enum_choice_list(_ON_OFF_SWITCH_VALUES))

    with ArgumentsContext(cli_command_loader, 'code pr') as ac:
        ac.argument('description',
                    type=str,
                    options_list=('--description', '-d'),
                    nargs='*')
        ac.argument('pull_request_id', type=int, options_list='--id')
        ac.argument('repository', options_list=('--repository', '-r'))
        ac.argument('source_branch', options_list=('--source-branch', '-s'))
        ac.argument('target_branch', options_list=('--target-branch', '-t'))
        ac.argument('title', type=str)

    with ArgumentsContext(cli_command_loader, 'code pr create') as ac:
        ac.argument('work_items', nargs='*')

    with ArgumentsContext(cli_command_loader, 'code pr list') as ac:
        ac.argument('status', **enum_choice_list(_PR_STATUS_VALUES))

    with ArgumentsContext(cli_command_loader, 'code pr reviewers') as ac:
        ac.argument('reviewers', nargs='+')

    with ArgumentsContext(cli_command_loader, 'code pr work-items') as ac:
        ac.argument('work_items', nargs='+')

    with ArgumentsContext(cli_command_loader, 'code pr update') as ac:
        ac.argument('auto_complete', **enum_choice_list(_ON_OFF_SWITCH_VALUES))
        ac.argument('squash', **enum_choice_list(_ON_OFF_SWITCH_VALUES))
        ac.argument('delete_source_branch',
                    **enum_choice_list(_ON_OFF_SWITCH_VALUES))
        ac.argument('bypass_policy', **enum_choice_list(_ON_OFF_SWITCH_VALUES))
        ac.argument('transition_work_items',
                    **enum_choice_list(_ON_OFF_SWITCH_VALUES))

    with ArgumentsContext(cli_command_loader, 'code pr policies') as ac:
        ac.argument('evaluation_id', options_list=('--evaluation-id', '-e'))

    with ArgumentsContext(cli_command_loader, 'code pr set-vote') as ac:
        ac.argument('vote', **enum_choice_list(_VOTE_VALUES))

    with ArgumentsContext(cli_command_loader, 'code repo') as ac:
        ac.argument('repo_id', options_list='--id')
示例#13
0
def load_work_arguments(cli_command_loader):
    with ArgumentsContext(cli_command_loader, 'work') as ac:
        ac.argument('open_browser', options_list='--open')
        ac.argument('project', options_list=('--project', '-p'))
        ac.argument('team_instance', options_list=('--instance', '-i'))
        ac.argument('detect', **enum_choice_list(_ON_OFF_SWITCH_VALUES))

    with ArgumentsContext(cli_command_loader, 'work item') as ac:
        ac.argument('work_item_id', type=int, options_list='--id')
        ac.argument('work_item_type', type=str, options_list='--type')
        ac.argument('fields', nargs='*', options_list=('--fields', '-f'))

    with ArgumentsContext(cli_command_loader, 'work item query') as ac:
        ac.argument('query_id', type=str, options_list='--id')
def load_code_arguments(self, _):
    with self.argument_context('repos') as context:
        context.argument('project', options_list=('--project', '-p'))
        context.argument('organization', options_list=('--organization', '--org'))
        context.argument('reviewers', nargs='*')
        context.argument('detect', **enum_choice_list(_ON_OFF_SWITCH_VALUES))

    with self.argument_context('repos pr') as context:
        context.argument('description', type=str, options_list=('--description', '-d'), nargs='*')
        context.argument('repository', options_list=('--repository', '-r'))
        context.argument('source_branch', options_list=('--source-branch', '-s'))
        context.argument('target_branch', options_list=('--target-branch', '-t'))
        context.argument('title', type=str)

    with self.argument_context('repos pr create') as context:
        context.argument('work_items', nargs='*')

    with self.argument_context('repos pr list') as context:
        context.argument('status', **enum_choice_list(_PR_STATUS_VALUES))

    with self.argument_context('repos pr reviewers') as context:
        context.argument('reviewers', nargs='+')

    with self.argument_context('repos pr work-items') as context:
        context.argument('work_items', nargs='+')

    with self.argument_context('repos pr update') as context:
        context.argument('auto_complete', **enum_choice_list(_ON_OFF_SWITCH_VALUES))
        context.argument('squash', **enum_choice_list(_ON_OFF_SWITCH_VALUES))
        context.argument('delete_source_branch', **enum_choice_list(_ON_OFF_SWITCH_VALUES))
        context.argument('bypass_policy', **enum_choice_list(_ON_OFF_SWITCH_VALUES))
        context.argument('transition_work_items', **enum_choice_list(_ON_OFF_SWITCH_VALUES))

    with self.argument_context('repos pr policies') as context:
        context.argument('evaluation_id', options_list=('--evaluation-id', '-e'))

    with self.argument_context('repos pr set-vote') as context:
        context.argument('vote', **enum_choice_list(_VOTE_VALUES))

    with self.argument_context('repos delete') as context:
        context.argument('yes', options_list=['--yes', '-y'], action='store_true',
                         help='Do not prompt for confirmation.')

    with self.argument_context('repos import create') as context:
        context.argument('repository', options_list=('--repository', '-r'))
        context.argument('git_source_url', options_list=('--git-source-url', '--git-url'))
def load_work_arguments(self, _):
    with self.argument_context('boards') as context:
        context.argument('project', options_list=('--project', '-p'))
        context.argument('organization', options_list=('--organization', '--org'))
        context.argument('detect', **enum_choice_list(_ON_OFF_SWITCH_VALUES))

    with self.argument_context('boards work-item create') as context:
        context.argument('work_item_type', type=str, options_list='--type')
        context.argument('fields', nargs='*', options_list=('--fields', '-f'))
        context.argument('description', options_list=('--description', '-d'))

    with self.argument_context('boards work-item update') as context:
        context.argument('fields', nargs='*', options_list=('--fields', '-f'))
        context.argument('description', options_list=('--description', '-d'))

    with self.argument_context('boards work-item delete') as context:
        context.argument('yes', options_list=['--yes', '-y'], action='store_true',
                         help='Do not prompt for confirmation.')
示例#16
0
def load_build_arguments(cli_command_loader):
    with ArgumentsContext(cli_command_loader, 'build') as ac:
        ac.argument('open_browser', options_list='--open')
        ac.argument('project', options_list=('--project', '-p'))
        ac.argument('team_instance', options_list=('--instance', '-i'))
        ac.argument('detect', **enum_choice_list(_ON_OFF_SWITCH_VALUES))

    with ArgumentsContext(cli_command_loader, 'build list') as ac:
        ac.argument('definition_ids', nargs='*', type=int)
        ac.argument('tags', nargs='*')

    with ArgumentsContext(cli_command_loader, 'build queue') as ac:
        ac.argument('definition_id', type=int)

    with ArgumentsContext(cli_command_loader, 'build show') as ac:
        ac.argument('build_id', options_list='--id', type=int)

    with ArgumentsContext(cli_command_loader, 'build definition show') as ac:
        ac.argument('definition_id', options_list='--id', type=int)
示例#17
0
def load_release_arguments(cli_command_loader):
    with ArgumentsContext(cli_command_loader, 'release') as ac:
        ac.argument('open_browser', options_list='--open')
        ac.argument('project', options_list=('--project', '-p'))
        ac.argument('team_instance', options_list=('--instance', '-i'))
        ac.argument('detect', **enum_choice_list(_ON_OFF_SWITCH_VALUES))

    with ArgumentsContext(cli_command_loader, 'release list') as ac:
        ac.argument('definition_id', type=int)

    with ArgumentsContext(cli_command_loader, 'release create') as ac:
        ac.argument('definition_id', type=int)
        ac.argument('artifact_metadata_list', nargs='*')

    with ArgumentsContext(cli_command_loader, 'release show') as ac:
        ac.argument('release_id', options_list='--id', type=int)

    with ArgumentsContext(cli_command_loader, 'release definition show') as ac:
        ac.argument('definition_id', options_list='--id', type=int)

    with ArgumentsContext(cli_command_loader, 'release definition list') as ac:
        ac.argument('artifact_type', choices=['build', 'jenkins', 'github', 'externaltfsbuild', 'git', 'tfvc'], type=str.lower)
示例#18
0
def load_release_arguments(cli_command_loader):
    with ArgumentsContext(cli_command_loader, 'release') as ac:
        ac.argument('open_browser', options_list='--open')
        ac.argument('project', options_list=('--project', '-p'))
        ac.argument('team_instance', options_list=('--instance', '-i'))
        ac.argument('detect', **enum_choice_list(_ON_OFF_SWITCH_VALUES))

    with ArgumentsContext(cli_command_loader, 'release list') as ac:
        ac.argument('definition_id', type=int)

    with ArgumentsContext(cli_command_loader, 'release create') as ac:
        ac.argument('definition_id', type=int)
        ac.argument('artifact_metadata_list', nargs='*')

    with ArgumentsContext(cli_command_loader, 'release show') as ac:
        ac.argument('release_id', options_list='--id', type=int)

    with ArgumentsContext(cli_command_loader, 'release definition show') as ac:
        ac.argument('definition_id', options_list='--id', type=int)

    with ArgumentsContext(cli_command_loader, 'release definition list') as ac:
        ac.argument('artifact_type', choices=['Build', 'Jenkins', 'GitHub', 'Nuget', 'Team Build (external)', 'ExternalTFSBuild', 'Git', 'TFVC', 'ExternalTfsXamlBuild'])
def load_team_arguments(self, _):
    with self.argument_context('devops configure') as context:
        context.argument('defaults',
                         options_list=('--defaults', '-d'),
                         nargs='*')
    with self.argument_context('devops project') as context:
        context.argument('process', options_list=('--process', '-p'))
        context.argument('source_control',
                         options_list=('--source-control', '-s'),
                         **enum_choice_list(_SOURCE_CONTROL_VALUES))
        context.argument('description', options_list=('--description', '-d'))
        context.argument('state', **enum_choice_list(_STATE_VALUES))
        context.argument('visibility',
                         **enum_choice_list(_PROJECT_VISIBILITY_VALUES))
    with self.argument_context('devops service-endpoint create') as context:
        context.argument('service_endpoint_type',
                         **enum_choice_list(_SERVICE_ENDPOINT_TYPE))
        context.argument(
            'authorization_scheme',
            **enum_choice_list(_SERVICE_ENDPOINT_AUTHORIZATION_SCHEME))
    with self.argument_context('devops project delete') as context:
        context.argument('yes',
                         options_list=['--yes', '-y'],
                         action='store_true',
                         help='Do not prompt for confirmation.')
    with self.argument_context('devops configure') as context:
        context.argument('use_git_aliases',
                         **enum_choice_list(_YES_NO_SWITCH_VALUES))
        context.argument('list_config', options_list=('--list', '-l'))

    with self.argument_context('devops') as context:
        load_global_args(context)

    with self.argument_context('repos') as context:
        load_global_args(context)

    with self.argument_context('artifacts') as context:
        load_global_args(context)

    with self.argument_context('boards') as context:
        load_global_args(context)

    with self.argument_context('pipelines') as context:
        load_global_args(context)
示例#20
0
 def load_command_table(self, args):
     super(ExtCommandsLoader, self).load_command_table(args)
     command = AzCliCommand(loader, 'test extension', test_handler)
     command.add_argument('opt', '--opt', required=True, **enum_choice_list(TestEnum))
     self.command_table['test extension'] = command
     return self.command_table
示例#21
0
def load_build_arguments(self, _):
    with self.argument_context('pipelines build list') as context:
        context.argument('definition_ids', nargs='*', type=int)
        context.argument('tags', nargs='*')
        context.argument('reason', **enum_choice_list(_BUILD_REASON_VALUES))
        context.argument('result', **enum_choice_list(_BUILD_RESULT_VALUES))
        context.argument('status', **enum_choice_list(_BUILD_STATUS_VALUES))

    with self.argument_context('pipelines build queue') as context:
        context.argument('definition_id', type=int)
        context.argument('variables', nargs='*')

    with self.argument_context('pipelines build definition list') as context:
        context.argument('repository_type',
                         choices=[
                             'tfsversioncontrol', 'tfsgit', 'git', 'github',
                             'githubenterprise', 'bitbucket', 'svn'
                         ],
                         type=str.lower)

    with self.argument_context('pipelines release list') as context:
        context.argument('definition_id', type=int)

    with self.argument_context('pipelines release create') as context:
        context.argument('definition_id', type=int)
        context.argument('artifact_metadata_list', nargs='*')

    with self.argument_context('pipelines release definition list') as context:
        context.argument('artifact_type',
                         choices=[
                             'build', 'jenkins', 'github', 'externaltfsbuild',
                             'git', 'tfvc'
                         ],
                         type=str.lower)

    with self.argument_context('pipelines runs list') as context:
        context.argument('pipeline_ids', nargs='*', type=int)
        context.argument('tags', nargs='*')
        context.argument('reason', **enum_choice_list(_BUILD_REASON_VALUES))
        context.argument('result', **enum_choice_list(_BUILD_RESULT_VALUES))
        context.argument('status', **enum_choice_list(_BUILD_STATUS_VALUES))
        context.argument('query_order',
                         **enum_choice_list(_PIPELINES_RUNS_QUERY_ORDER))

    with self.argument_context('pipelines run') as context:
        context.argument('id', type=int)
        context.argument('parameters', nargs='*')
        context.argument('variables', nargs='*')

    with self.argument_context('pipelines list') as context:
        context.argument('query_order',
                         **enum_choice_list(_PIPELINES_QUERY_ORDER))
        context.argument('repository_type',
                         choices=[
                             'tfsversioncontrol', 'tfsgit', 'git', 'github',
                             'githubenterprise', 'bitbucket', 'svn'
                         ],
                         type=str.lower)

    with self.argument_context('pipelines create') as context:
        context.argument('repository_type',
                         choices=['tfsgit', 'github'],
                         type=str.lower)
        context.argument('yml_path',
                         options_list=('--yml-path', '--yaml-path'))
        context.argument('skip_first_run',
                         options_list=['--skip-first-run', '--skip-run'],
                         arg_type=get_three_state_flag())

    with self.argument_context('pipelines update') as context:
        context.argument('yml_path',
                         options_list=('--yml-path', '--yaml-path'))

    with self.argument_context('pipelines pool') as context:
        context.argument('pool_id', options_list=('--pool-id', '--id'))
        context.argument('action', **enum_choice_list(_ACTION_FILTER_TYPES))
        context.argument('pool_type', **enum_choice_list(_AGENT_POOL_TYPES))

    with self.argument_context('pipelines agent') as context:
        context.argument('agent_id', options_list=('--agent-id', '--id'))
        context.argument('include_capabilities',
                         arg_type=get_three_state_flag())
        context.argument('include_assigned_request',
                         arg_type=get_three_state_flag())
        context.argument('include_last_completed_request',
                         arg_type=get_three_state_flag())

    with self.argument_context('pipelines queue') as context:
        context.argument('queue_id', options_list=('--queue-id', '--id'))
        context.argument('action', **enum_choice_list(_ACTION_FILTER_TYPES))

    with self.argument_context('pipelines variable-group') as context:
        context.argument('group_id', options_list=('--group-id', '--id'))
        context.argument('variables', nargs='*')
        context.argument('query_order',
                         **enum_choice_list(_VAR_GROUPS_QUERY_ORDER))
        context.argument('action_filter',
                         options_list=('--action-filter', '--action'),
                         **enum_choice_list(_ACTION_FILTER_TYPES))
        context.argument('secret', arg_type=get_three_state_flag())
        context.argument('authorize', arg_type=get_three_state_flag())
        context.argument('prompt_value', arg_type=get_three_state_flag())

    with self.argument_context('pipelines variable') as context:
        context.argument('secret', arg_type=get_three_state_flag())
        context.argument('prompt_value', arg_type=get_three_state_flag())
        context.argument('allow_override', arg_type=get_three_state_flag())

    with self.argument_context('pipelines folder') as context:
        context.argument('query_order',
                         **enum_choice_list(_FOLDERS_QUERY_ORDER))
示例#22
0
def load_team_arguments(self, _):
    with self.argument_context('devops login') as context:
        context.argument('organization',
                         help='Azure DevOps organization URL. Example: https://dev.azure.com/MyOrganizationName')

    with self.argument_context('devops logout') as context:
        context.argument('organization',
                         help='Azure DevOps organization URL. Example: https://dev.azure.com/MyOrganizationName/. '
                         'If no organization is specified, all organizations will be logged out.')

    with self.argument_context('devops configure') as context:
        context.argument('defaults', options_list=('--defaults', '-d'), nargs='*')
        context.argument('use_git_aliases', arg_type=get_three_state_flag())
        context.argument('list_config', options_list=('--list', '-l'))

    with self.argument_context('devops') as context:
        context.argument('repository', options_list=('--repository', '-r'))

    with self.argument_context('devops project') as context:
        context.argument('process', options_list=('--process', '-p'))
        context.argument('source_control', options_list=('--source-control', '-s'),
                         **enum_choice_list(_SOURCE_CONTROL_VALUES))
        context.argument('description', options_list=('--description', '-d'))
        context.argument('state', **enum_choice_list(_STATE_VALUES))
        context.argument('visibility', **enum_choice_list(_PROJECT_VISIBILITY_VALUES))

    with self.argument_context('devops project delete') as context:
        context.argument('yes', options_list=['--yes', '-y'], action='store_true',
                         help='Do not prompt for confirmation.')

    with self.argument_context('devops service-endpoint create') as context:
        context.argument('encoding',
                         help='Encoding of the input file.',
                         **enum_choice_list(_FILE_ENCODING_TYPE_VALUES))

    with self.argument_context('devops invoke') as context:
        context.argument('route_parameters', nargs='*',
                         help='Specifies the list of route parameters')
        context.argument('query_parameters', nargs='*',
                         help='Specifies the list of query parameters')
        context.argument('http_method', arg_type=get_enum_type(_HTTP_METHOD_VALUES),
                         help='Specifies the method used for the request.')
        context.argument('media_type',
                         help='Specifies the content type of the request.')
        context.argument('accept_media_type',
                         help='Specifies the content type of the response.')
        context.argument('in_file',
                         help='Path and file name to the file that contains the contents of the request.')
        context.argument('encoding',
                         help='Encoding of the input file. Used in conjunction with --in-file.',
                         **enum_choice_list(_FILE_ENCODING_TYPE_VALUES))
        context.argument('out_file',
                         help='Path and file name to the file  for which this function saves the response body.')
        context.argument('area',
                         help='The area to find the resource.')
        context.argument('resource',
                         help='The name of the resource to operate on.')
        context.argument('api_version',
                         help='The version of the API to target')

    with self.argument_context('devops user') as context:
        context.argument('license_type', arg_type=get_enum_type(_LICENSE_TYPES))
    with self.argument_context('devops user add') as context:
        context.argument('send_email_invite', arg_type=get_three_state_flag(),
                         help='Whether to send email invite for new user or not.')

    with self.argument_context('devops security group create') as context:
        context.argument('project',
                         help='Name or ID of the project in which Azure DevOps group should be created.')
        context.argument('scope', **enum_choice_list(_SCOPE_VALUES))

    with self.argument_context('devops security group list') as context:
        context.argument('project',
                         help='List groups for a particular project')
        context.argument('scope', **enum_choice_list(_SCOPE_VALUES))

    with self.argument_context('devops security group membership') as context:
        context.argument('relationship', arg_type=get_enum_type(_RELATIONSHIP_TYPES),
                         help='Get member of/members for this group.')

    with self.argument_context('devops security permission') as context:
        context.argument('namespace_id', options_list=('--namespace-id', '--id'),
                         help='ID of security namespace')
        context.argument('token',
                         help='Security token.')
        context.argument('subject',
                         help='User Email ID or Group descriptor')

    with self.argument_context('devops security permission update') as context:
        context.argument('merge', arg_type=get_three_state_flag(),
                         help='If set, the existing ACE has its allow and deny merged with \
                         the incoming ACE\'s allow and deny. If unset, the existing ACE is displaced.')
        context.argument('allow_bit', type=int,
                         help='Allow bit or addition of bits. Required if --deny-bit is missing.')
        context.argument('deny_bit', type=int,
                         help='Deny bit or addition of bits. Required if --allow-bit is missing.')

    with self.argument_context('devops security permission reset') as context:
        context.argument('permission_bit', type=int,
                         help='Permission bit or addition of permission bits which needs to be reset\
                         for given user/group and token.')

    with self.argument_context('devops extension') as context:
        context.argument('include_built_in', arg_type=get_three_state_flag(),
                         help='Include built in extensions.')
        context.argument('include_disabled', arg_type=get_three_state_flag(),
                         help='Include disabled extensions.')
        context.argument('publisher_name', help='Publisher Name')
        context.argument('extension_name', help='Extension Name')
        context.argument('search_query', options_list=('--search-query', '-q'), help='Search term')

    with self.argument_context('devops') as context:
        load_global_args(context)

    with self.argument_context('repos') as context:
        load_global_args(context)

    with self.argument_context('artifacts') as context:
        load_global_args(context)

    with self.argument_context('boards') as context:
        load_global_args(context)

    with self.argument_context('pipelines') as context:
        load_global_args(context)

    with self.argument_context('devops wiki') as context:
        context.argument('wiki_type', options_list=('--wiki-type', '--type'), **enum_choice_list(_WIKI_TYPE_VALUES))
        context.argument('version', options_list=('--version', '-v'))
        context.argument('encoding', **enum_choice_list(_FILE_ENCODING_TYPE_VALUES))

    with self.argument_context('devops wiki list') as context:
        context.argument('scope', **enum_choice_list(_SCOPE_VALUES))
def load_team_arguments(self, _):
    with self.argument_context('devops configure') as context:
        context.argument('defaults',
                         options_list=('--defaults', '-d'),
                         nargs='*')
    with self.argument_context('devops project') as context:
        context.argument('process', options_list=('--process', '-p'))
        context.argument('source_control',
                         options_list=('--source-control', '-s'),
                         **enum_choice_list(_SOURCE_CONTROL_VALUES))
        context.argument('description', options_list=('--description', '-d'))
        context.argument('state', **enum_choice_list(_STATE_VALUES))
        context.argument('visibility',
                         **enum_choice_list(_PROJECT_VISIBILITY_VALUES))
    with self.argument_context('devops service-endpoint create') as context:
        context.argument('service_endpoint_type',
                         **enum_choice_list(_SERVICE_ENDPOINT_TYPE))
        context.argument(
            'authorization_scheme',
            **enum_choice_list(_SERVICE_ENDPOINT_AUTHORIZATION_SCHEME))
    with self.argument_context('devops project delete') as context:
        context.argument('yes',
                         options_list=['--yes', '-y'],
                         action='store_true',
                         help='Do not prompt for confirmation.')
    with self.argument_context('devops configure') as context:
        context.argument('use_git_aliases',
                         **enum_choice_list(_YES_NO_SWITCH_VALUES))
        context.argument('list_config', options_list=('--list', '-l'))

    with self.argument_context('devops invoke') as context:
        context.argument('route_parameters',
                         nargs='*',
                         help='Specifies the list of route parameters')
        context.argument('query_parameters',
                         nargs='*',
                         help='Specifies the list of query parameters')
        context.argument('http_method',
                         arg_type=get_enum_type(_HTTP_METHOD_VALUES),
                         help='Specifies the method used for the request.')
        context.argument('media_type',
                         help='Specifies the content type of the request.')
        context.argument('accept_media_type',
                         help='Specifies the content type of the response.')
        context.argument(
            'in_file',
            help=
            'Path and file name to the file that contains the contents of the request.'
        )
        context.argument(
            'out_file',
            help=
            'Path and file name to the file  for which this function saves the response body.'
        )
        context.argument('area', help='The area to find the resource.')
        context.argument('resource',
                         help='The name of the resource to operate on.')
        context.argument('api_version',
                         help='The version of the API to target')

    with self.argument_context('devops user') as context:
        context.argument('license_type',
                         arg_type=get_enum_type(_LICENSE_TYPES))
    with self.argument_context('devops user add') as context:
        context.argument(
            'send_email_invite',
            arg_type=get_enum_type(_TRUE_FALSE_SWITCH),
            help='Whether to send email invite for new user or not.')

    with self.argument_context('devops extension') as context:
        context.argument('include_built_in',
                         arg_type=get_enum_type(_TRUE_FALSE_SWITCH),
                         help='Include built in extensions.')
        context.argument('include_disabled',
                         arg_type=get_enum_type(_TRUE_FALSE_SWITCH),
                         help='Include disabled extensions.')
        context.argument('publisher_id', help='Publisher ID')
        context.argument('extension_id', help='Extension ID')
        context.argument('search_query',
                         options_list=('--search-query', '-q'),
                         help='Search term')

    with self.argument_context('devops') as context:
        load_global_args(context)

    with self.argument_context('repos') as context:
        load_global_args(context)

    with self.argument_context('artifacts') as context:
        load_global_args(context)

    with self.argument_context('boards') as context:
        load_global_args(context)

    with self.argument_context('pipelines') as context:
        load_global_args(context)
def load_code_arguments(self, _):
    with self.argument_context('repos') as context:
        context.argument('repository', options_list=('--repository', '-r'))
        context.argument('reviewers', nargs='*')

    with self.argument_context('repos policy') as context:
        context.argument(
            'policy_configuration',
            options_list=('--policy-configuration', '--config'),
            help='Local file path for configuration file. ' +
            'Please use / backslash when typing in directory path. ')
        context.argument('policy_id',
                         options_list=('--policy-id', '--id'),
                         help='ID of the policy.')
        context.argument(
            'repository_id',
            help='Id of the repository on which to apply the policy')
        context.argument(
            'branch',
            help=
            'Branch on which this policy should be applied. For example: master'
        )
        context.argument(
            'branch_match_type',
            arg_type=get_enum_type(_BRANCH_MATCH_KIND_VALUES),
            help=
            'Determines how the branch argument is used to apply a policy. ' +
            'If value is \'exact\', the policy will be applied on a branch which has an '
            + 'exact match on the --branch argument. ' +
            'If value is \'prefix\' the policy is applied across all branch folders that '
            + 'match the prefix provided by the --branch argument.')
        context.argument('blocking',
                         arg_type=get_three_state_flag(),
                         help='Whether the policy should be blocking or not')
        context.argument('enabled',
                         arg_type=get_three_state_flag(),
                         help='Whether the policy is enabled or not')
        context.argument(
            'path_filter',
            help='Filter path(s) on which the policy is applied. ' +
            'Supports absolute paths, wildcards and multiple paths separated by \';\'. '
            + 'Example: /WebApp/Models/Data.cs, /WebApp/* or *.cs,' +
            '/WebApp/Models/Data.cs;ClientApp/Models/Data.cs')

    with self.argument_context('repos policy list') as context:
        context.argument(
            'branch',
            help='Branch name to filter results by exact match of branch name. '
            +
            'The --repository-id parameter is required to use the branch filter. '
            + 'For example: --branch master')
        context.argument(
            'repository_id',
            help=
            'ID of the repository to filter results by exact match of the repository ID. '
            +
            'For example --repository-ID e556f204-53c9-4153-9cd9-ef41a11e3345')

    with self.argument_context('repos policy approver-count') as context:
        context.argument(
            'minimum_approver_count',
            help='Minimum number of approvers required. For example: 2')
        context.argument('creator_vote_counts',
                         arg_type=get_three_state_flag(),
                         help='Whether the creator\'s vote counts or not.')
        context.argument('allow_downvotes',
                         arg_type=get_three_state_flag(),
                         help='Whether to allow downvotes or not.')
        context.argument('reset_on_source_push',
                         arg_type=get_three_state_flag(),
                         help='Whether to reset source on push.')

    with self.argument_context('repos policy merge-strategy') as context:
        context.argument(
            'use_squash_merge',
            arg_type=get_three_state_flag(),
            help='Whether to squash merge always. '
            'This option does not work for allowing other merge types.',
            deprecate_info=context.deprecate(redirect='--allow-squash',
                                             target='--use-squash-merge',
                                             hide=True))
        context.argument(
            'allow_squash',
            arg_type=get_three_state_flag(),
            help=
            'Squash merge - Creates a linear history by condensing the source branch commits '
            'into a single new commit on the target branch.')
        context.argument(
            'allow_rebase',
            arg_type=get_three_state_flag(),
            help=
            'Rebase and fast-forward - Creates a linear history by replaying the source branch '
            'commits onto the target without a merge commit.')
        context.argument(
            'allow_no_fast_forward',
            arg_type=get_three_state_flag(),
            help=
            'Basic merge (no fast-forward) - Preserves nonlinear history exactly as it happened '
            'during development.')
        context.argument(
            'allow_rebase_merge',
            arg_type=get_three_state_flag(),
            help=
            'Rebase with merge commit - Creates a semi-linear history by replaying the source '
            'branch commits onto the target and then creating a merge commit.')

    with self.argument_context('repos policy build') as context:
        context.argument('build_definition_id', help='Build Definition Id.')
        context.argument('queue_on_source_update_only',
                         arg_type=get_three_state_flag(),
                         help='Queue Only on source update.')
        context.argument('manual_queue_only',
                         arg_type=get_three_state_flag(),
                         help='Whether to allow only manual queue of builds.')
        context.argument(
            'display_name',
            help='Display name for this build policy to identify the policy. '
            + 'For example: \'Manual queue policy\'')
        context.argument('valid_duration',
                         help='Policy validity duration (in minutes).')

    with self.argument_context('repos policy file-size') as context:
        context.argument(
            'maximum_git_blob_size',
            help='Maximum git blob size in bytes. ' +
            'For example, to specify a 10byte limit, --maximum-git-blob-size 10.'
        )
        context.argument('use_uncompressed_size',
                         arg_type=get_three_state_flag(),
                         help='Whether to use uncompressed size.')

    with self.argument_context('repos policy required-reviewer') as context:
        context.argument(
            'required_reviewer_ids',
            help='Required reviewers email addresses separated by \';\'. ' +
            'For example: [email protected];[email protected]')
        context.argument('message', help='Message.')

    with self.argument_context('repos pr') as context:
        context.argument('description',
                         type=str,
                         options_list=('--description', '-d'),
                         nargs='*')
        context.argument('source_branch',
                         options_list=('--source-branch', '-s'))
        context.argument('target_branch',
                         options_list=('--target-branch', '-t'))
        context.argument('title', type=str)

    with self.argument_context('repos pr create') as context:
        context.argument('work_items', nargs='*')
        context.argument('draft', arg_type=get_three_state_flag())
        context.argument('auto_complete', arg_type=get_three_state_flag())
        context.argument('squash', arg_type=get_three_state_flag())
        context.argument('delete_source_branch',
                         arg_type=get_three_state_flag())
        context.argument('bypass_policy', arg_type=get_three_state_flag())
        context.argument('transition_work_items',
                         arg_type=get_three_state_flag())

    with self.argument_context('repos pr list') as context:
        context.argument('status', **enum_choice_list(_PR_STATUS_VALUES))

    with self.argument_context('repos pr reviewer') as context:
        context.argument('reviewers', nargs='+')

    with self.argument_context('repos pr work-item') as context:
        context.argument('work_items', nargs='+')

    with self.argument_context('repos pr update') as context:
        context.argument('auto_complete', arg_type=get_three_state_flag())
        context.argument('squash', arg_type=get_three_state_flag())
        context.argument('delete_source_branch',
                         arg_type=get_three_state_flag())
        context.argument('bypass_policy', arg_type=get_three_state_flag())
        context.argument('transition_work_items',
                         arg_type=get_three_state_flag())
        context.argument('draft', arg_type=get_three_state_flag())
        context.argument('status',
                         **enum_choice_list(_PR_TARGET_STATUS_VALUES))

    with self.argument_context('repos pr policy') as context:
        context.argument('evaluation_id',
                         options_list=('--evaluation-id', '-e'))

    with self.argument_context('repos pr set-vote') as context:
        context.argument('vote', **enum_choice_list(_VOTE_VALUES))

    with self.argument_context('repos delete') as context:
        context.argument('yes',
                         options_list=['--yes', '-y'],
                         action='store_true',
                         help='Do not prompt for confirmation.')

    with self.argument_context('repos import create') as context:
        context.argument('git_source_url',
                         options_list=('--git-source-url', '--git-url'))

    with self.argument_context('repos ref') as context:
        context.argument('repository', options_list=('--repository', '-r'))
        context.argument('object_id', options_list=('--object-id'))