示例#1
0
        static CommandLineConfigs()
        {
            UninstallRootCommand.AddOption(new Option("--version", LocalizableStrings.VersionOptionDescription));
            DryRunCommand.AddAlias(WhatIfCommandName);

            UninstallRootCommand.AddCommand(ListCommand);
            UninstallRootCommand.AddCommand(DryRunCommand);
            UninstallRootCommand.AddCommand(RemoveCommand);

            var supportedBundleTypeNames = SupportedBundleTypeConfigs.GetSupportedBundleTypes().Select(type => type.OptionName);

            RemoveAuxOptions = UninstallBundleTypeOptions
                               .Where(option => supportedBundleTypeNames.Contains(option.Name))
                               .Concat(AdditionalUninstallOptions)
                               .Append(YesOption);
            if (RuntimeInfo.RunningOnWindows)
            {
                RemoveAuxOptions = RemoveAuxOptions.Concat(ArchUninstallOptions);
            }
            AssignOptionsToCommand(RemoveCommand, RemoveAuxOptions
                                   .Concat(UninstallFilterBundlesOptions), true);

            DryRunAuxOptions = UninstallBundleTypeOptions
                               .Where(option => supportedBundleTypeNames.Contains(option.Name))
                               .Concat(AdditionalUninstallOptions);
            if (RuntimeInfo.RunningOnWindows)
            {
                DryRunAuxOptions = DryRunAuxOptions.Concat(ArchUninstallOptions);
            }
            AssignOptionsToCommand(DryRunCommand, DryRunAuxOptions
                                   .Concat(UninstallFilterBundlesOptions), true);

            ListAuxOptions = ListBundleTypeOptions
                             .Where(option => supportedBundleTypeNames.Contains(option.Name))
                             .Append(VerbosityOption);
            if (RuntimeInfo.RunningOnWindows)
            {
                ListAuxOptions = ListAuxOptions
                                 .Append(ListX64Option)
                                 .Append(ListX86Option);
            }
            AssignOptionsToCommand(ListCommand, ListAuxOptions);

            ListCommand.Handler   = CommandHandler.Create(ExceptionHandler.HandleException(() => ListCommandExec.Execute()));
            DryRunCommand.Handler = CommandHandler.Create(ExceptionHandler.HandleException(() => DryRunCommandExec.Execute()));
            RemoveCommand.Handler = CommandHandler.Create(ExceptionHandler.HandleException(() => UninstallCommandExec.Execute()));

            UninstallCommandParser = new CommandLineBuilder(UninstallRootCommand)
                                     .UseDefaults()
                                     .UseHelpBuilder(context => new UninstallHelpBuilder(context.Console))
                                     .Build();
            CommandLineParseResult = UninstallCommandParser.Parse(Environment.GetCommandLineArgs());
        }
示例#2
0
        static CommandLineConfigs()
        {
            UninstallRootCommand.AddArgument(new Argument <IEnumerable <string> >
            {
                Name        = LocalizableStrings.UninstallNoOptionArgumentName,
                Description = LocalizableStrings.UninstallNoOptionArgumentDescription
            });

            UninstallRootCommand.AddCommand(ListCommand);

            var supportedBundleTypeNames = SupportedBundleTypeConfigs.GetSupportedBundleTypes().Select(type => type.OptionName);

            var supportedUninstallBundleTypeOptions = new Option[]
            {
                UninstallSdkOption,
                UninstallRuntimeOption,
                UninstallAspNetRuntimeOption,
                UninstallHostingBundleOption
            }
            .Where(option => supportedBundleTypeNames.Contains(option.Name));

            var supportedListBundleTypeOptions = new Option[]
            {
                ListSdkOption,
                ListRuntimeOption,
                ListAspNetRuntimeOption,
                ListHostingBundleOption
            }
            .Where(option => supportedBundleTypeNames.Contains(option.Name));

            UninstallAuxOptions = supportedUninstallBundleTypeOptions
                                  .Append(VerbosityOption)
                                  .Append(UninstallX64Option)
                                  .Append(UninstallX86Option)
                                  .Append(VersionOption)
                                  .Append(DryRunOption)
                                  .Append(YesOption);

            ListAuxOptions = supportedListBundleTypeOptions
                             .Append(VerbosityOption)
                             .Append(ListX64Option)
                             .Append(ListX86Option);

            foreach (var option in UninstallMainOptions
                     .Concat(UninstallAuxOptions)
                     .OrderBy(option => option.Name))
            {
                UninstallRootCommand.AddOption(option);
            }

            foreach (var option in ListAuxOptions
                     .OrderBy(option => option.Name))
            {
                ListCommand.AddOption(option);
            }

            ListCommand.Handler          = CommandHandler.Create(ExceptionHandler.HandleException(() => ListCommandExec.Execute()));
            UninstallRootCommand.Handler = CommandHandler.Create(ExceptionHandler.HandleException(() => UninstallCommandExec.Execute()));

            CommandLineParseResult = UninstallRootCommand.Parse(Environment.GetCommandLineArgs());
        }