Beispiel #1
0
def __process_arguments(args: list):
    parser = ArgumentParser(
        description='DotNet Cli wrapper.',
        allow_abbrev=False
    )
    subparsers = parser.add_subparsers(
        title='Subcommands',
        description='Supported DotNet Cli subcommands',
        dest='install',
    )
    subparsers.required = True

    install_parser = subparsers.add_parser(
        'install',
        allow_abbrev=False,
        help='Installs dotnet cli',
    )

    install_parser.add_argument(
        '--channels',
        dest='channels',
        required=False,
        nargs='+',
        default=['main'],
        choices= ChannelMap.get_supported_channels(),
        help='Download DotNet Cli from the Channel specified.'
    )

    install_parser = __add_arguments(install_parser)

    # private install arguments.
    install_parser.add_argument(
        '--install-dir',
        dest='install_dir',
        required=False,
        type=str,
        help='''Path to where to install dotnet. Note that binaries will be '''
             '''placed directly in a given directory.''',
    )
    install_parser.add_argument(
        '-v', '--verbose',
        required=False,
        default=False,
        action='store_true',
        help='Turns on verbosity (default "False")',
    )
    return parser.parse_args(args)
Beispiel #2
0
def add_arguments(parser: ArgumentParser) -> ArgumentParser:
    '''Adds new arguments to the specified ArgumentParser object.'''

    if not isinstance(parser, ArgumentParser):
        raise TypeError('Invalid parser.')

    # Download DotNet Cli
    dotnet.add_arguments(parser)
    micro_benchmarks.add_arguments(parser)

    parser.add_argument('--channel',
                        dest='channel',
                        required=True,
                        choices=ChannelMap.get_supported_channels(),
                        type=str,
                        help='Channel to download product from')

    parser.add_argument('--branch',
                        dest='branch',
                        required=False,
                        type=str,
                        help='Product branch.')
    parser.add_argument('--commit-sha',
                        dest='commit_sha',
                        required=False,
                        type=str,
                        help='Product commit sha.')
    parser.add_argument('--repository',
                        dest='repository',
                        required=False,
                        type=str,
                        help='Product repository.')
    parser.add_argument('--queue',
                        dest='queue',
                        default='testQueue',
                        required=False,
                        type=str,
                        help='Test queue')
    parser.add_argument('--build-number',
                        dest='build_number',
                        default='1234.1',
                        required=False,
                        type=str,
                        help='Build number')

    parser.add_argument('--locale',
                        dest='locale',
                        default='en-US',
                        required=False,
                        type=str,
                        help='Locale')
    parser.add_argument('--perf-hash',
                        dest='perf_hash',
                        default='testSha',
                        required=False,
                        type=str,
                        help='Sha of the performance repo')

    parser.add_argument('--get-perf-hash',
                        dest="get_perf_hash",
                        required=False,
                        action='store_true',
                        default=False,
                        help='Discover the hash of the performance repository')

    parser.add_argument('--output-file',
                        dest='output_file',
                        required=False,
                        default=os.path.join(
                            get_tools_directory(),
                            'machine-setup' + global_extension),
                        type=str,
                        help='Filename to write the setup script to')

    parser.add_argument('--install-dir',
                        dest='install_dir',
                        required=False,
                        type=str,
                        help='Directory to install dotnet to')

    # Generic arguments.
    parser.add_argument(
        '-q',
        '--quiet',
        required=False,
        default=False,
        action='store_true',
        help='Turns off verbosity.',
    )

    parser.add_argument(
        '--build-configs',
        dest="build_configs",
        required=False,
        nargs='+',
        default=[],
        help='Configurations used in the build in key=value format')

    return parser
def add_arguments(parser: ArgumentParser) -> ArgumentParser:
    '''Adds new arguments to the specified ArgumentParser object.'''

    if not isinstance(parser, ArgumentParser):
        raise TypeError('Invalid parser.')

    # Download DotNet Cli
    dotnet.add_arguments(parser)
    micro_benchmarks.add_arguments(parser)

    parser.add_argument('--channel',
                        dest='channel',
                        required=True,
                        choices=ChannelMap.get_supported_channels(),
                        type=str,
                        help='Channel to download product from')
    parser.add_argument('--no-pgo',
                        dest='pgo_status',
                        required=False,
                        action='store_const',
                        const='nopgo')
    parser.add_argument('--dynamic-pgo',
                        dest='pgo_status',
                        required=False,
                        action='store_const',
                        const='dynamicpgo')
    parser.add_argument('--full-pgo',
                        dest='pgo_status',
                        required=False,
                        action='store_const',
                        const='fullpgo')
    parser.add_argument('--branch',
                        dest='branch',
                        required=False,
                        type=str,
                        help='Product branch.')
    parser.add_argument('--commit-sha',
                        dest='commit_sha',
                        required=False,
                        type=str,
                        help='Product commit sha.')
    parser.add_argument('--repository',
                        dest='repository',
                        required=False,
                        type=str,
                        help='Product repository.')
    parser.add_argument('--queue',
                        dest='queue',
                        default='testQueue',
                        required=False,
                        type=str,
                        help='Test queue')
    parser.add_argument('--build-number',
                        dest='build_number',
                        default='1234.1',
                        required=False,
                        type=str,
                        help='Build number')

    parser.add_argument('--locale',
                        dest='locale',
                        default='en-US',
                        required=False,
                        type=str,
                        help='Locale')
    parser.add_argument('--perf-hash',
                        dest='perf_hash',
                        default='testSha',
                        required=False,
                        type=str,
                        help='Sha of the performance repo')

    parser.add_argument('--get-perf-hash',
                        dest="get_perf_hash",
                        required=False,
                        action='store_true',
                        default=False,
                        help='Discover the hash of the performance repository')

    parser.add_argument('--output-file',
                        dest='output_file',
                        required=False,
                        default=os.path.join(
                            get_tools_directory(),
                            'machine-setup' + global_extension),
                        type=str,
                        help='Filename to write the setup script to')

    parser.add_argument('--install-dir',
                        dest='install_dir',
                        required=False,
                        type=str,
                        help='Directory to install dotnet to')

    parser.add_argument('--not-in-lab',
                        dest='not_in_lab',
                        required=False,
                        action='store_true',
                        default=False,
                        help='Indicates that this is not running in perflab')

    def __is_valid_dotnet_path(dp: str) -> str:
        if not os.path.isdir(dp):
            raise ArgumentTypeError('Path {} does not exist'.format(dp))
        if not os.path.isfile(os.path.join(dp, 'dotnet')):
            raise ArgumentTypeError('Could not find dotnet in {}'.format(dp))
        return dp

    parser.add_argument('--dotnet-path',
                        dest='dotnet_path',
                        required=False,
                        type=__is_valid_dotnet_path,
                        help='Path to a custom dotnet')

    # Generic arguments.
    parser.add_argument(
        '-q',
        '--quiet',
        required=False,
        default=False,
        action='store_true',
        help='Turns off verbosity.',
    )

    parser.add_argument(
        '--build-configs',
        dest="build_configs",
        required=False,
        nargs='+',
        default=[],
        help='Configurations used in the build in key=value format')

    parser.add_argument('--maui-version',
                        dest='maui_version',
                        default='',
                        required=False,
                        type=str,
                        help='Version of Maui used to build app packages')
    return parser