public static Command ToolInstall()
 {
     return(Create.Command("install",
                           LocalizableStrings.CommandDescription,
                           Accept.ExactlyOneArgument(errorMessage: o => LocalizableStrings.SpecifyExactlyOnePackageId)
                           .With(name: LocalizableStrings.PackageIdArgumentName,
                                 description: LocalizableStrings.PackageIdArgumentDescription),
                           Create.Option(
                               "-g|--global",
                               LocalizableStrings.GlobalOptionDescription,
                               Accept.NoArguments()),
                           Create.Option(
                               "--tool-path",
                               LocalizableStrings.ToolPathOptionDescription,
                               Accept.ExactlyOneArgument()
                               .With(name: LocalizableStrings.ToolPathOptionName)),
                           Create.Option(
                               "--version",
                               LocalizableStrings.VersionOptionDescription,
                               Accept.ExactlyOneArgument()
                               .With(name: LocalizableStrings.VersionOptionName)),
                           Create.Option(
                               "--configfile",
                               LocalizableStrings.ConfigFileOptionDescription,
                               Accept.ExactlyOneArgument()
                               .With(name: LocalizableStrings.ConfigFileOptionName)),
                           Create.Option(
                               "--add-source",
                               LocalizableStrings.AddSourceOptionDescription,
                               Accept.OneOrMoreArguments()
                               .With(name: LocalizableStrings.AddSourceOptionName)),
                           Create.Option(
                               "--framework",
                               LocalizableStrings.FrameworkOptionDescription,
                               Accept.ExactlyOneArgument()
                               .With(name: LocalizableStrings.FrameworkOptionName)),
                           CommonOptions.HelpOption(),
                           CommonOptions.VerbosityOption()));
 }
Esempio n. 2
0
        public void A_materializer_can_be_specified_using_options_and_arguments_to_create_an_object()
        {
            var parser = new Parser(
                Command("move", "",
                        arguments: Accept.OneOrMoreArguments()
                        .MaterializeAs(p =>
            {
                output.WriteLine(p.ToString());

                return(new FileMoveOperation
                {
                    Files = p.Arguments.Select(f => new FileInfo(f)).ToList(),
                    Destination = new DirectoryInfo(p["destination"].Arguments.Single())
                });
            }),
                        options: new[]
            {
                Option("-d|--destination", "", Accept.ExactlyOneArgument())
            }));

            var folder = new DirectoryInfo(Path.Combine("temp"));
            var file1  = new FileInfo(Path.Combine(folder.FullName, "the file.txt"));
            var file2  = new FileInfo(Path.Combine(folder.FullName, "the other file.txt"));

            var result = parser.Parse($@"move -d ""{folder}"" ""{file1}"" ""{file2}""");

            var fileMoveOperation = result["move"].Value <FileMoveOperation>();

            fileMoveOperation.Destination
            .FullName
            .Should()
            .Be(folder.FullName);

            fileMoveOperation.Files
            .Select(f => f.FullName)
            .Should()
            .BeEquivalentTo(file2.FullName,
                            file1.FullName);
        }
Esempio n. 3
0
 public static Command ToolUpdate()
 {
     return(Create.Command("update",
                           LocalizableStrings.CommandDescription,
                           Accept.ExactlyOneArgument(errorMessage: o => LocalizableStrings.SpecifyExactlyOnePackageId)
                           .With(name: LocalizableStrings.PackageIdArgumentName,
                                 description: LocalizableStrings.PackageIdArgumentDescription),
                           Create.Option(
                               "-g|--global",
                               LocalizableStrings.GlobalOptionDescription,
                               Accept.NoArguments()),
                           Create.Option(
                               "--tool-path",
                               LocalizableStrings.ToolPathOptionDescription,
                               Accept.ExactlyOneArgument()
                               .With(name: LocalizableStrings.ToolPathOptionName)),
                           Create.Option(
                               "--configfile",
                               LocalizableStrings.ConfigFileOptionDescription,
                               Accept.ExactlyOneArgument()
                               .With(name: LocalizableStrings.ConfigFileOptionName)),
                           Create.Option(
                               "--add-source",
                               LocalizableStrings.AddSourceOptionDescription,
                               Accept.OneOrMoreArguments()
                               .With(name: LocalizableStrings.AddSourceOptionName)),
                           Create.Option(
                               "--framework",
                               LocalizableStrings.FrameworkOptionDescription,
                               Accept.ExactlyOneArgument()
                               .With(name: LocalizableStrings.FrameworkOptionName)),
                           ToolCommandRestorePassThroughOptions.DisableParallelOption(),
                           ToolCommandRestorePassThroughOptions.IgnoreFailedSourcesOption(),
                           ToolCommandRestorePassThroughOptions.NoCacheOption(),
                           ToolCommandRestorePassThroughOptions.InteractiveRestoreOption(),
                           CommonOptions.HelpOption(),
                           CommonOptions.VerbosityOption()));
 }
 public static Command ListPackageReferences() => Create.Command(
     "package",
     LocalizableStrings.AppFullName,
     Accept.NoArguments(),
     CommonOptions.HelpOption(),
     Create.Option("--outdated",
                   LocalizableStrings.CmdOutdatedDescription,
                   Accept.NoArguments().ForwardAs("--outdated")),
     Create.Option("--framework",
                   LocalizableStrings.CmdFrameworkDescription,
                   Accept.OneOrMoreArguments()
                   .With(name: LocalizableStrings.CmdFramework)
                   .ForwardAsMany(o => ForwardedArguments("--framework", o.Arguments))),
     Create.Option("--include-transitive",
                   LocalizableStrings.CmdTransitiveDescription,
                   Accept.NoArguments().ForwardAs("--include-transitive")),
     Create.Option("--include-prerelease",
                   LocalizableStrings.CmdPrereleaseDescription,
                   Accept.NoArguments().ForwardAs("--include-prerelease")),
     Create.Option("--highest-patch",
                   LocalizableStrings.CmdHighestPatchDescription,
                   Accept.NoArguments().ForwardAs("--highest-patch")),
     Create.Option("--highest-minor",
                   LocalizableStrings.CmdHighestMinorDescription,
                   Accept.NoArguments().ForwardAs("--highest-minor")),
     Create.Option("--config",
                   LocalizableStrings.CmdConfigDescription,
                   Accept.ExactlyOneArgument()
                   .With(name: LocalizableStrings.CmdConfig)
                   .ForwardAsMany(o => new [] { "--config", o.Arguments.Single() })),
     Create.Option("--source",
                   LocalizableStrings.CmdSourceDescription,
                   Accept.OneOrMoreArguments()
                   .With(name: LocalizableStrings.CmdSource)
                   .ForwardAsMany(o => ForwardedArguments("--source", o.Arguments))),
     Create.Option("--interactive",
                   CommonLocalizableStrings.CommandInteractiveOptionDescription,
                   Accept.NoArguments().ForwardAs("--interactive")));
 public static Command Publish() =>
 CreateWithRestoreOptions.Command(
     "publish",
     LocalizableStrings.AppDescription,
     Accept.ZeroOrMoreArguments(),
     CommonOptions.HelpOption(),
     Create.Option(
         "-o|--output",
         LocalizableStrings.OutputOptionDescription,
         Accept.ExactlyOneArgument()
         .With(name: LocalizableStrings.OutputOption)
         .ForwardAsSingle(o => $"-property:PublishDir={o.Arguments.Single()}")),
     CommonOptions.FrameworkOption(),
     CommonOptions.RuntimeOption(),
     CommonOptions.ConfigurationOption(),
     CommonOptions.VersionSuffixOption(),
     Create.Option(
         "--manifest",
         LocalizableStrings.ManifestOptionDescription,
         Accept.OneOrMoreArguments()
         .With(name: LocalizableStrings.ManifestOption)
         .ForwardAsSingle(o => $"-property:TargetManifestFiles={string.Join("%3B", o.Arguments)}")),
     Create.Option(
         "--no-build",
         LocalizableStrings.NoBuildOptionDescription,
         Accept.NoArguments().ForwardAs("-property:NoBuild=true")),
     Create.Option(
         "--self-contained",
         LocalizableStrings.SelfContainedOptionDescription,
         Accept.ZeroOrOneArgument()
         .WithSuggestionsFrom("true", "false")
         .ForwardAsSingle(o =>
 {
     string value = o.Arguments.Any() ? o.Arguments.Single() : "true";
     return($"-property:SelfContained={value}");
 })),
     CommonOptions.NoRestoreOption(),
     CommonOptions.VerbosityOption());
Esempio n. 6
0
 public static Command Run() =>
 Create.Command(
     "run",
     LocalizableStrings.AppFullName,
     treatUnmatchedTokensAsErrors: false,
     arguments: Accept.ZeroOrMoreArguments()
     .MaterializeAs(o => new RunCommand
                    (
                        configuration: o.SingleArgumentOrDefault("--configuration"),
                        framework: o.SingleArgumentOrDefault("--framework"),
                        noBuild: o.HasOption("--no-build"),
                        project: o.SingleArgumentOrDefault("--project"),
                        launchProfile: o.SingleArgumentOrDefault("--launch-profile"),
                        noLaunchProfile: o.HasOption("--no-launch-profile"),
                        args: o.Arguments
                    )),
     options: new[]
 {
     CommonOptions.HelpOption(),
     CommonOptions.ConfigurationOption(),
     CommonOptions.FrameworkOption(),
     Create.Option(
         "-p|--project",
         LocalizableStrings.CommandOptionProjectDescription,
         Accept.ExactlyOneArgument()),
     Create.Option(
         "--launch-profile",
         LocalizableStrings.CommandOptionLaunchProfileDescription,
         Accept.ExactlyOneArgument()),
     Create.Option(
         "--no-launch-profile",
         LocalizableStrings.CommandOptionNoLaunchProfileDescription,
         Accept.NoArguments()),
     Create.Option(
         "--no-build",
         LocalizableStrings.CommandOptionNoBuildDescription,
         Accept.NoArguments())
 });
Esempio n. 7
0
 public static Command Publish() =>
 Create.Command(
     "publish",
     LocalizableStrings.AppFullName,
     Accept.ZeroOrMoreArguments(),
     CommonOptions.HelpOption(),
     CommonOptions.FrameworkOption(),
     CommonOptions.RuntimeOption(),
     Create.Option(
         "-o|--output",
         LocalizableStrings.OutputOptionDescription,
         Accept.ExactlyOneArgument()
         .With(name: LocalizableStrings.OutputOption)
         .ForwardAsSingle(o => $"/p:PublishDir={o.Arguments.Single()}")),
     CommonOptions.ConfigurationOption(),
     CommonOptions.VersionSuffixOption(),
     Create.Option(
         "--filter",
         LocalizableStrings.FilterProjOptionDescription,
         Accept.OneOrMoreArguments()
         .With(name: LocalizableStrings.FilterProjOption)
         .ForwardAsSingle(o => $"/p:FilterProjectFiles={string.Join("%3B", o.Arguments)}")),
     CommonOptions.VerbosityOption());
Esempio n. 8
0
 public static Command Clean() =>
 Create.Command(
     "clean",
     LocalizableStrings.AppFullName,
     Accept.ZeroOrMoreArguments()
     .With(name: CommonLocalizableStrings.SolutionOrProjectArgumentName,
           description: CommonLocalizableStrings.SolutionOrProjectArgumentDescription),
     CommonOptions.HelpOption(),
     Create.Option("-o|--output",
                   LocalizableStrings.CmdOutputDirDescription,
                   Accept.ExactlyOneArgument()
                   .With(name: LocalizableStrings.CmdOutputDir)
                   .ForwardAsSingle(o => $"-property:OutputPath={CommandDirectoryContext.GetFullPath(o.Arguments.Single())}")),
     Create.Option(
         "--nologo|/nologo",
         LocalizableStrings.CmdNoLogo,
         Accept.NoArguments()
         .ForwardAs("-nologo")),
     CommonOptions.FrameworkOption(LocalizableStrings.FrameworkOptionDescription),
     CommonOptions.RuntimeOption(LocalizableStrings.RuntimeOptionDescription),
     CommonOptions.ConfigurationOption(LocalizableStrings.ConfigurationOptionDescription),
     CommonOptions.InteractiveMsBuildForwardOption(),
     CommonOptions.VerbosityOption());
Esempio n. 9
0
 public static Command AddPackage()
 {
     return(Create.Command(
                "package",
                LocalizableStrings.AppFullName,
                Accept.ExactlyOneArgument(errorMessage: o => LocalizableStrings.SpecifyExactlyOnePackageReference)
                .WithSuggestionsFrom(QueryNuGet)
                .With(name: LocalizableStrings.CmdPackage,
                      description: LocalizableStrings.CmdPackageDescription),
                CommonOptions.HelpOption(),
                Create.Option("-v|--version",
                              LocalizableStrings.CmdVersionDescription,
                              Accept.ExactlyOneArgument()
                              .With(name: LocalizableStrings.CmdVersion)
                              .ForwardAsSingle(o => $"--version {o.Arguments.Single()}")),
                Create.Option("-f|--framework",
                              LocalizableStrings.CmdFrameworkDescription,
                              Accept.ExactlyOneArgument()
                              .With(name: LocalizableStrings.CmdFramework)
                              .ForwardAsSingle(o => $"--framework {o.Arguments.Single()}")),
                Create.Option("-n|--no-restore",
                              LocalizableStrings.CmdNoRestoreDescription),
                Create.Option("-s|--source",
                              LocalizableStrings.CmdSourceDescription,
                              Accept.ExactlyOneArgument()
                              .With(name: LocalizableStrings.CmdSource)
                              .ForwardAsSingle(o => $"--source {o.Arguments.Single()}")),
                Create.Option("--package-directory",
                              LocalizableStrings.CmdPackageDirectoryDescription,
                              Accept.ExactlyOneArgument()
                              .With(name: LocalizableStrings.CmdPackageDirectory)
                              .ForwardAsSingle(o => $"--package-directory {o.Arguments.Single()}")),
                Create.Option("--interactive",
                              CommonLocalizableStrings.CommandInteractiveOptionDescription,
                              Accept.NoArguments()
                              .ForwardAs("--interactive"))));
 }
Esempio n. 10
0
 public Cli.CommandLine.Command Migrate() =>
 Create.Command(
     "migrate",
     ".NET Migrate Command",
     Accept.ZeroOrOneArgument()
     .MaterializeAs(o =>
                    new MigrateCommand.MigrateCommand(
                        new CallStage0DotnetSlnToManipulateSolutionFile(),
                        new CallStage0DotnetNewToAddTemplate(),
                        o.ValueOrDefault <string>("--template-file"),
                        o.Arguments.FirstOrDefault(),
                        o.ValueOrDefault <string>("--sdk-package-version"),
                        o.ValueOrDefault <string>("--xproj-file"),
                        o.ValueOrDefault <string>("--report-file"),
                        o.ValueOrDefault <bool>("--skip-project-references"),
                        o.ValueOrDefault <bool>("--format-report-file-json"),
                        o.ValueOrDefault <bool>("--skip-backup"), (l) => _stdOut.Append(l)))
     .With(name: "",
           description: ""),
     Create.Option("-t|--template-file",
                   "",
                   Accept.ExactlyOneArgument()),
     Create.Option("-v|--sdk-package-version",
                   "",
                   Accept.ExactlyOneArgument()),
     Create.Option("-x|--xproj-file",
                   "",
                   Accept.ExactlyOneArgument()),
     Create.Option("-s|--skip-project-references",
                   ""),
     Create.Option("-r|--report-file",
                   "",
                   Accept.ExactlyOneArgument()),
     Create.Option("--format-report-file-json",
                   ""),
     Create.Option("--skip-backup",
                   ""));
Esempio n. 11
0
 public static Command Migrate() =>
 Create.Command(
     "migrate",
     ".NET Migrate Command",
     Accept.ZeroOrOneArgument()
     .MaterializeAs(o =>
                    new MigrateCommand(
                        o.ValueOrDefault <string>("--template-file"),
                        o.Arguments.FirstOrDefault(),
                        o.ValueOrDefault <string>("--sdk-package-version"),
                        o.ValueOrDefault <string>("--xproj-file"),
                        o.ValueOrDefault <string>("--report-file"),
                        o.ValueOrDefault <bool>("--skip-project-references"),
                        o.ValueOrDefault <bool>("--format-report-file-json"),
                        o.ValueOrDefault <bool>("--skip-backup")))
     .With(name: LocalizableStrings.CmdProjectArgument,
           description: LocalizableStrings.CmdProjectArgumentDescription),
     CommonOptions.HelpOption(),
     Create.Option("-t|--template-file",
                   LocalizableStrings.CmdTemplateDescription,
                   Accept.ExactlyOneArgument()),
     Create.Option("-v|--sdk-package-version",
                   LocalizableStrings.CmdVersionDescription,
                   Accept.ExactlyOneArgument()),
     Create.Option("-x|--xproj-file",
                   LocalizableStrings.CmdXprojFileDescription,
                   Accept.ExactlyOneArgument()),
     Create.Option("-s|--skip-project-references",
                   LocalizableStrings.CmdSkipProjectReferencesDescription),
     Create.Option("-r|--report-file",
                   LocalizableStrings.CmdReportFileDescription,
                   Accept.ExactlyOneArgument()),
     Create.Option("--format-report-file-json",
                   LocalizableStrings.CmdReportOutputDescription),
     Create.Option("--skip-backup",
                   LocalizableStrings.CmdSkipBackupDescription));
Esempio n. 12
0
        public static Command Test() =>
        Create.Command(
            "test",
            LocalizableStrings.AppFullName,
            Accept.ZeroOrMoreArguments()
            .With(name: LocalizableStrings.CmdArgProject,
                  description: LocalizableStrings.CmdArgDescription),
            CommonOptions.HelpOption(),
            Create.Option(
                "-s|--settings",
                LocalizableStrings.CmdSettingsDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.CmdSettingsFile)
                .ForwardAsSingle(o => $"/p:VSTestSetting={o.Arguments.Single()}")),
            Create.Option(
                "-t|--list-tests",
                LocalizableStrings.CmdListTestsDescription,
                Accept.NoArguments()
                .ForwardAsSingle(o => "/p:VSTestListTests=true")),
            Create.Option(
                "--filter",
                LocalizableStrings.CmdTestCaseFilterDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.CmdTestCaseFilterExpression)
                .ForwardAsSingle(o => $"/p:VSTestTestCaseFilter={o.Arguments.Single()}")),
            Create.Option(
                "-a|--test-adapter-path",
                LocalizableStrings.CmdTestAdapterPathDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.CmdTestAdapterPath)
                .ForwardAsSingle(o => $"/p:VSTestTestAdapterPath={o.Arguments.Single()}")),
            Create.Option(
                "-l|--logger",
                LocalizableStrings.CmdLoggerDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.CmdLoggerOption)
                .ForwardAsSingle(o =>
        {
            var loggersString = string.Join(";", GetSemiColonEscapedArgs(o.Arguments));

            return($"/p:VSTestLogger={loggersString}");
        })),
            CommonOptions.ConfigurationOption(),
            CommonOptions.FrameworkOption(),
            Create.Option(
                "-o|--output",
                LocalizableStrings.CmdOutputDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.CmdOutputDir)
                .ForwardAsSingle(o => $"/p:OutputPath={o.Arguments.Single()}")),
            Create.Option(
                "-d|--diag",
                LocalizableStrings.CmdPathTologFileDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.CmdPathToLogFile)
                .ForwardAsSingle(o => $"/p:VSTestDiag={o.Arguments.Single()}")),
            Create.Option(
                "--no-build",
                LocalizableStrings.CmdNoBuildDescription,
                Accept.NoArguments()
                .ForwardAsSingle(o => "/p:VSTestNoBuild=true")),
            Create.Option(
                "-r|--results-directory",
                LocalizableStrings.CmdResultsDirectoryDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.CmdPathToResultsDirectory)
                .ForwardAsSingle(o => $"/p:VSTestResultsDirectory={o.Arguments.Single()}")),
            CommonOptions.VerbosityOption());
Esempio n. 13
0
        public static Command Store() =>
        Create.Command(
            "store",
            LocalizableStrings.AppDescription,
            Accept.ZeroOrMoreArguments(),
            CommonOptions.HelpOption(),
            Create.Option(
                "-m|--manifest",
                LocalizableStrings.ProjectManifestDescription,
                Accept.OneOrMoreArguments()
                .With(name: LocalizableStrings.ProjectManifest)
                .ForwardAsMany(o =>
        {
            var materializedString = $"{o.Arguments.First()}";

            if (o.Arguments.Count == 1)
            {
                return(new[]
                {
                    materializedString
                });
            }
            else
            {
                return(new[]
                {
                    materializedString,
                    $"/p:AdditionalProjects={string.Join("%3B", o.Arguments.Skip(1))}"
                });
            }
        })),
            CommonOptions.FrameworkOption(),
            Create.Option(
                "--framework-version",
                LocalizableStrings.FrameworkVersionOptionDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.FrameworkVersionOption)
                .ForwardAsSingle(o => $"/p:RuntimeFrameworkVersion={o.Arguments.Single()}")),
            CommonOptions.RuntimeOption(),
            CommonOptions.ConfigurationOption(),
            Create.Option(
                "-o|--output",
                LocalizableStrings.OutputOptionDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.OutputOption)
                .ForwardAsSingle(o => $"/p:ComposeDir={Path.GetFullPath(o.Arguments.Single())}")),
            Create.Option(
                "-w|--working-dir",
                LocalizableStrings.IntermediateWorkingDirOptionDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.IntermediateWorkingDirOption)
                .ForwardAsSingle(o => $"/p:ComposeWorkingDir={o.Arguments.Single()}")),
            Create.Option(
                "--preserve-working-dir",
                LocalizableStrings.PreserveIntermediateWorkingDirOptionDescription,
                Accept.NoArguments()
                .ForwardAsSingle(o => $"/p:PreserveComposeWorkingDir=true")),
            Create.Option(
                "--skip-optimization",
                LocalizableStrings.SkipOptimizationOptionDescription,
                Accept.NoArguments()
                .ForwardAs("/p:SkipOptimization=true")),
            CommonOptions.VerbosityOption());
Esempio n. 14
0
        public static Command Test() =>
        Create.Command(
            "test",
            LocalizableStrings.AppFullName,
            Accept.ZeroOrMoreArguments()
            .With(name: CommonLocalizableStrings.ProjectArgumentName,
                  description: CommonLocalizableStrings.ProjectArgumentDescription),
            false,
            CommonOptions.HelpOption(),
            Create.Option(
                "-s|--settings",
                LocalizableStrings.CmdSettingsDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.CmdSettingsFile)
                .ForwardAsSingle(o => $"-property:VSTestSetting={o.Arguments.Single()}")),
            Create.Option(
                "-t|--list-tests",
                LocalizableStrings.CmdListTestsDescription,
                Accept.NoArguments()
                .ForwardAsSingle(o => "-property:VSTestListTests=true")),
            Create.Option(
                "--filter",
                LocalizableStrings.CmdTestCaseFilterDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.CmdTestCaseFilterExpression)
                .ForwardAsSingle(o => $"-property:VSTestTestCaseFilter={o.Arguments.Single()}")),
            Create.Option(
                "-a|--test-adapter-path",
                LocalizableStrings.CmdTestAdapterPathDescription,
                Accept.OneOrMoreArguments()
                .With(name: LocalizableStrings.CmdTestAdapterPath)
                .ForwardAsSingle(o => $"-property:VSTestTestAdapterPath=\"{string.Join(";", o.Arguments)}\"")),
            Create.Option(
                "-l|--logger",
                LocalizableStrings.CmdLoggerDescription,
                Accept.OneOrMoreArguments()
                .With(name: LocalizableStrings.CmdLoggerOption)
                .ForwardAsSingle(o =>
        {
            var loggersString = string.Join(";", GetSemiColonEscapedArgs(o.Arguments));

            return($"-property:VSTestLogger=\"{loggersString}\"");
        })),
            CommonOptions.ConfigurationOption(LocalizableStrings.ConfigurationOptionDescription),
            CommonOptions.FrameworkOption(LocalizableStrings.FrameworkOptionDescription),
            CommonOptions.RuntimeOption(LocalizableStrings.RuntimeOptionDescription, withShortOption: false),
            Create.Option(
                "-o|--output",
                LocalizableStrings.CmdOutputDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.CmdOutputDir)
                .ForwardAsSingle(o => $"-property:OutputPath={o.Arguments.Single()}")),
            Create.Option(
                "-d|--diag",
                LocalizableStrings.CmdPathTologFileDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.CmdPathToLogFile)
                .ForwardAsSingle(o => $"-property:VSTestDiag={o.Arguments.Single()}")),
            Create.Option(
                "--no-build",
                LocalizableStrings.CmdNoBuildDescription,
                Accept.NoArguments()
                .ForwardAsSingle(o => "-property:VSTestNoBuild=true")),
            Create.Option(
                "-r|--results-directory",
                LocalizableStrings.CmdResultsDirectoryDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.CmdPathToResultsDirectory)
                .ForwardAsSingle(o => $"-property:VSTestResultsDirectory={o.Arguments.Single()}")),
            Create.Option(
                "--collect",
                LocalizableStrings.cmdCollectDescription,
                Accept.OneOrMoreArguments()
                .With(name: LocalizableStrings.cmdCollectFriendlyName)
                .ForwardAsSingle(o => $"-property:VSTestCollect=\"{string.Join(";", o.Arguments)}\"")),
            Create.Option(
                "--blame",
                LocalizableStrings.CmdBlameDescription,
                Accept.NoArguments()
                .ForwardAsSingle(o => "-property:VSTestBlame=true")),
            CommonOptions.NoRestoreOption(),
            CommonOptions.VerbosityOption());
 public static Command InternalReportinstallsuccess() =>
 Create.Command(
     "internal-reportinstallsuccess", "internal only",
     Accept.ExactlyOneArgument());
Esempio n. 16
0
        public static Command Test() =>
        Create.Command(
            "test",
            LocalizableStrings.AppFullName,
            Accept.ZeroOrMoreArguments()
            .With(name: CommonLocalizableStrings.SolutionOrProjectArgumentName,
                  description: CommonLocalizableStrings.SolutionOrProjectArgumentDescription),
            false,
            CommonOptions.HelpOption(),
            Create.Option(
                "-s|--settings",
                LocalizableStrings.CmdSettingsDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.CmdSettingsFile)
                .ForwardAsSingle(o => $"-property:VSTestSetting={CommandDirectoryContext.GetFullPath(o.Arguments.Single())}")),
            Create.Option(
                "-t|--list-tests",
                LocalizableStrings.CmdListTestsDescription,
                Accept.NoArguments()
                .ForwardAsSingle(o => "-property:VSTestListTests=true")),
            Create.Option(
                "--filter",
                LocalizableStrings.CmdTestCaseFilterDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.CmdTestCaseFilterExpression)
                .ForwardAsSingle(o => $"-property:VSTestTestCaseFilter={o.Arguments.Single()}")),
            Create.Option(
                "-a|--test-adapter-path",
                LocalizableStrings.CmdTestAdapterPathDescription,
                Accept.OneOrMoreArguments()
                .With(name: LocalizableStrings.CmdTestAdapterPath)
                .ForwardAsSingle(o => $"-property:VSTestTestAdapterPath=\"{string.Join(";", o.Arguments.Select(CommandDirectoryContext.GetFullPath))}\"")),
            Create.Option(
                "-l|--logger",
                LocalizableStrings.CmdLoggerDescription,
                Accept.OneOrMoreArguments()
                .With(name: LocalizableStrings.CmdLoggerOption)
                .ForwardAsSingle(o =>
        {
            var loggersString = string.Join(";", GetSemiColonEscapedArgs(o.Arguments));

            return($"-property:VSTestLogger=\"{loggersString}\"");
        })),
            CommonOptions.ConfigurationOption(LocalizableStrings.ConfigurationOptionDescription),
            CommonOptions.FrameworkOption(LocalizableStrings.FrameworkOptionDescription),
            CommonOptions.RuntimeOption(LocalizableStrings.RuntimeOptionDescription, withShortOption: false),
            Create.Option(
                "-o|--output",
                LocalizableStrings.CmdOutputDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.CmdOutputDir)
                .ForwardAsSingle(o => $"-property:OutputPath={CommandDirectoryContext.GetFullPath(o.Arguments.Single())}")),
            Create.Option(
                "-d|--diag",
                LocalizableStrings.CmdPathTologFileDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.CmdPathToLogFile)
                .ForwardAsSingle(o => $"-property:VSTestDiag={CommandDirectoryContext.GetFullPath(o.Arguments.Single())}")),
            Create.Option(
                "--no-build",
                LocalizableStrings.CmdNoBuildDescription,
                Accept.NoArguments()
                .ForwardAsSingle(o => "-property:VSTestNoBuild=true")),
            Create.Option(
                "-r|--results-directory",
                LocalizableStrings.CmdResultsDirectoryDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.CmdPathToResultsDirectory)
                .ForwardAsSingle(o => $"-property:VSTestResultsDirectory={CommandDirectoryContext.GetFullPath(o.Arguments.Single())}")),
            Create.Option(
                "--collect",
                LocalizableStrings.cmdCollectDescription,
                Accept.OneOrMoreArguments()
                .With(name: LocalizableStrings.cmdCollectFriendlyName)
                .ForwardAsSingle(o => $"-property:VSTestCollect=\"{string.Join(";", o.Arguments)}\"")),
            Create.Option(
                "--blame",
                LocalizableStrings.CmdBlameDescription,
                Accept.NoArguments()
                .ForwardAsSingle(o => "-property:VSTestBlame=true")),
            Create.Option(
                "--blame-crash",
                LocalizableStrings.CmdBlameCrashDescription,
                Accept.NoArguments()
                .ForwardAsSingle(o => "-property:VSTestBlameCrash=true")),
            Create.Option(
                "--blame-crash-dump-type",
                LocalizableStrings.CmdBlameCrashDumpTypeDescription,
                Accept.AnyOneOf(
                    "full",
                    "mini")
                .With(name: LocalizableStrings.CrashDumpTypeArgumentName, defaultValue: () => "full")
                .ForwardAsMany(o => new[] {
            "-property:VSTestBlameCrash=true",
            $"-property:VSTestBlameCrashDumpType={o.Arguments.Single()}"
        })),
            Create.Option(
                "--blame-crash-collect-always",
                LocalizableStrings.CmdBlameCrashCollectAlwaysDescription,
                Accept.NoArguments()
                .ForwardAsMany(o => new[] {
            "-property:VSTestBlameCrash=true",
            "-property:VSTestBlameCrashCollectAlways=true"
        })),
            Create.Option(
                "--blame-hang",
                LocalizableStrings.CmdBlameHangDescription,
                Accept.NoArguments()
                .ForwardAsSingle(o => "-property:VSTestBlameHang=true")),
            Create.Option(
                "--blame-hang-dump-type",
                LocalizableStrings.CmdBlameHangDumpTypeDescription,
                Accept.AnyOneOf(
                    "full",
                    "mini",
                    "none")
                .With(name: LocalizableStrings.HangDumpTypeArgumentName, defaultValue: () => "full")
                .ForwardAsMany(o => new[] {
            "-property:VSTestBlameHang=true",
            $"-property:VSTestBlameHangDumpType={o.Arguments.Single()}"
        })),
            Create.Option(
                "--blame-hang-timeout",
                LocalizableStrings.CmdBlameHangTimeoutDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.HangTimeoutArgumentName)
                .ForwardAsMany(o => new[] {
            "-property:VSTestBlameHang=true",
            $"-property:VSTestBlameHangTimeout={o.Arguments.Single()}"
        })),

            Create.Option(
                "--nologo|/nologo",
                LocalizableStrings.CmdNoLogo,
                Accept.NoArguments()
                .ForwardAsSingle(o => "-property:VSTestNoLogo=nologo")),
            CommonOptions.NoRestoreOption(),
            CommonOptions.InteractiveMsBuildForwardOption(),
            CommonOptions.VerbosityOption());
Esempio n. 17
0
 public static Command SlnAdd() =>
 Create.Command("add",
                LocalizableStrings.AddAppFullName,
                Accept.OneOrMoreArguments(o => CommonLocalizableStrings.SpecifyAtLeastOneProjectToAdd)
                .With(name: LocalizableStrings.AddProjectPathArgumentName,
                      description: LocalizableStrings.AddProjectPathArgumentDescription),
                Create.Option(
                    "--in-root",
                    LocalizableStrings.InRoot,
                    Accept.NoArguments()),
                Create.Option("-s|--solution-folder", LocalizableStrings.AddProjectSolutionFolderArgumentDescription, Accept.ExactlyOneArgument()),
                CommonOptions.HelpOption());
Esempio n. 18
0
        // Creates a command setup with the args for "new", plus args for the input template parameters.
        public static Command CreateNewCommandWithArgsForTemplate(string commandName, string templateName,
                                                                  IReadOnlyList <ITemplateParameter> parameterDefinitions,
                                                                  IDictionary <string, string> longNameOverrides,
                                                                  IDictionary <string, string> shortNameOverrides,
                                                                  out IReadOnlyDictionary <string, IReadOnlyList <string> > templateParamMap)
        {
            IList <Option> paramOptionList = new List <Option>();

            Option[] allBuiltInArgs = ArrayExtensions.CombineArrays(NewCommandVisibleArgs, NewCommandHiddenArgs, NewCommandReservedArgs, DebuggingCommandArgs);

            HashSet <string> initiallyTakenAliases = VariantsForOptions(allBuiltInArgs);
            Dictionary <string, IReadOnlyList <string> > canonicalToVariantMap = new Dictionary <string, IReadOnlyList <string> >();
            AliasAssignmentCoordinator assignmentCoordinator = new AliasAssignmentCoordinator(parameterDefinitions, longNameOverrides, shortNameOverrides, initiallyTakenAliases);

            if (assignmentCoordinator.InvalidParams.Count > 0)
            {
                string unusableDisplayList = string.Join(", ", assignmentCoordinator.InvalidParams);
                throw new Exception($"Template is malformed. The following parameter names are invalid: {unusableDisplayList}");
            }

            foreach (ITemplateParameter parameter in parameterDefinitions.Where(x => x.Priority != TemplateParameterPriority.Implicit))
            {
                Option         option;
                IList <string> aliasesForParam = new List <string>();

                if (assignmentCoordinator.LongNameAssignments.TryGetValue(parameter.Name, out string longVersion))
                {
                    aliasesForParam.Add(longVersion);
                }

                if (assignmentCoordinator.ShortNameAssignments.TryGetValue(parameter.Name, out string shortVersion))
                {
                    aliasesForParam.Add(shortVersion);
                }

                if (string.Equals(parameter.DataType, "choice", StringComparison.OrdinalIgnoreCase))
                {
                    option = Create.Option(string.Join("|", aliasesForParam), parameter.Documentation,
                                           Accept.ExactlyOneArgument()
                                           //.WithSuggestionsFrom(parameter.Choices.Keys.ToArray())
                                           .With(defaultValue: () => parameter.DefaultValue));
                }
                else if (string.Equals(parameter.DataType, "bool", StringComparison.OrdinalIgnoreCase))
                {
                    option = Create.Option(string.Join("|", aliasesForParam), parameter.Documentation,
                                           Accept.ZeroOrOneArgument()
                                           .WithSuggestionsFrom(new[] { "true", "false" }));
                }
                else
                {
                    option = Create.Option(string.Join("|", aliasesForParam), parameter.Documentation,
                                           Accept.ExactlyOneArgument());
                }

                paramOptionList.Add(option);                                         // add the option
                canonicalToVariantMap.Add(parameter.Name, aliasesForParam.ToList()); // map the template canonical name to its aliases.
            }

            templateParamMap = canonicalToVariantMap;
            return(GetNewCommandForTemplate(commandName, templateName, NewCommandVisibleArgs, NewCommandHiddenArgs, DebuggingCommandArgs, paramOptionList.ToArray()));
        }
Esempio n. 19
0
        public static Command Store() =>
        Create.Command(
            "store",
            LocalizableStrings.AppDescription,
            Accept.ZeroOrMoreArguments(),
            CommonOptions.HelpOption(),
            Create.Option(
                "-m|--manifest",
                LocalizableStrings.ProjectManifestDescription,
                Accept.OneOrMoreArguments()
                .With(name: LocalizableStrings.ProjectManifest)
                .ForwardAsMany(o =>
        {
            // the first path doesn't need to go through CommandDirectoryContext.ExpandPath
            // since it is a direct argument to MSBuild, not a property
            var materializedString = $"{o.Arguments.First()}";

            if (o.Arguments.Count == 1)
            {
                return(new[]
                {
                    materializedString
                });
            }
            else
            {
                return(new[]
                {
                    materializedString,
                    $"-property:AdditionalProjects={string.Join("%3B", o.Arguments.Skip(1).Select(CommandDirectoryContext.GetFullPath))}"
                });
            }
        })),
            CommonOptions.FrameworkOption(LocalizableStrings.FrameworkOptionDescription),
            Create.Option(
                "--framework-version",
                LocalizableStrings.FrameworkVersionOptionDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.FrameworkVersionOption)
                .ForwardAsSingle(o => $"-property:RuntimeFrameworkVersion={o.Arguments.Single()}")),
            CommonOptions.RuntimeOption(LocalizableStrings.RuntimeOptionDescription),
            Create.Option(
                "-o|--output",
                LocalizableStrings.OutputOptionDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.OutputOption)
                .ForwardAsSingle(o => $"-property:ComposeDir={CommandDirectoryContext.GetFullPath(o.Arguments.Single())}")),
            Create.Option(
                "-w|--working-dir",
                LocalizableStrings.IntermediateWorkingDirOptionDescription,
                Accept.ExactlyOneArgument()
                .With(name: LocalizableStrings.IntermediateWorkingDirOption)
                .ForwardAsSingle(o => $"-property:ComposeWorkingDir={CommandDirectoryContext.GetFullPath(o.Arguments.Single())}")),
            Create.Option(
                "--skip-optimization",
                LocalizableStrings.SkipOptimizationOptionDescription,
                Accept.NoArguments()
                .ForwardAs("-property:SkipOptimization=true")),
            Create.Option(
                "--skip-symbols",
                LocalizableStrings.SkipSymbolsOptionDescription,
                Accept.NoArguments()
                .ForwardAs("-property:CreateProfilingSymbols=false")),
            CommonOptions.VerbosityOption());
Esempio n. 20
0
 public static Command NuGet() =>
 Create.Command(
     "nuget",
     Parser.CompletionOnlyDescription,
     Create.Option("-h|--help", Parser.CompletionOnlyDescription),
     Create.Option("--version", Parser.CompletionOnlyDescription),
     Create.Option("-v|--verbosity", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()),
     Create.Command(
         "delete",
         Parser.CompletionOnlyDescription,
         Accept.OneOrMoreArguments(),
         Create.Option("-h|--help", Parser.CompletionOnlyDescription),
         Create.Option("--force-english-output", Parser.CompletionOnlyDescription),
         Create.Option("-s|--source", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()),
         Create.Option("--non-interactive", Parser.CompletionOnlyDescription),
         Create.Option("-k|--api-key", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()),
         Create.Option("--no-service-endpoint", Parser.CompletionOnlyDescription),
         Create.Option("--interactive", Parser.CompletionOnlyDescription)),
     Create.Command(
         "locals",
         Parser.CompletionOnlyDescription,
         Accept.AnyOneOf(
             "all",
             "http-cache",
             "global-packages",
             "plugins-cache",
             "temp"),
         Create.Option("-h|--help", Parser.CompletionOnlyDescription),
         Create.Option("--force-english-output", Parser.CompletionOnlyDescription),
         Create.Option("-c|--clear", Parser.CompletionOnlyDescription),
         Create.Option("-l|--list", Parser.CompletionOnlyDescription)),
     Create.Command(
         "push",
         Parser.CompletionOnlyDescription,
         Accept.OneOrMoreArguments(),
         Create.Option("-h|--help", Parser.CompletionOnlyDescription),
         Create.Option("--force-english-output", Parser.CompletionOnlyDescription),
         Create.Option("-s|--source", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()),
         Create.Option("-ss|--symbol-source", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()),
         Create.Option("-t|--timeout", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()),
         Create.Option("-k|--api-key", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()),
         Create.Option("-sk|--symbol-api-key", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()),
         Create.Option("-d|--disable-buffering", Parser.CompletionOnlyDescription),
         Create.Option("-n|--no-symbols", Parser.CompletionOnlyDescription),
         Create.Option("--no-service-endpoint", Parser.CompletionOnlyDescription),
         Create.Option("--interactive", Parser.CompletionOnlyDescription)
         ));
Esempio n. 21
0
 public static Command NuGet() =>
 Create.Command("nuget",
                "NuGet Command Line 4.0.0.0",
                CommonOptions.HelpOption(),
                Create.Option("--version",
                              "Show version information"),
                Create.Option("-v|--verbosity",
                              "The verbosity of logging to use. Allowed values: Debug, Verbose, Information, Minimal, Warning, Error.",
                              Accept.ExactlyOneArgument()
                              .With(name: "verbosity")),
                Create.Command("delete",
                               "Deletes a package from the server.",
                               Accept.ExactlyOneArgument()
                               .With(name: "root",
                                     description: "The Package Id and version."),
                               CommonOptions.HelpOption(),
                               Create.Option("--force-english-output",
                                             "Forces the application to run using an invariant, English-based culture."),
                               Create.Option("-s|--source",
                                             "Specifies the server URL",
                                             Accept.ExactlyOneArgument()
                                             .With(name: "source")),
                               Create.Option("--non-interactive",
                                             "Do not prompt for user input or confirmations."),
                               Create.Option("-k|--api-key",
                                             "The API key for the server.",
                                             Accept.ExactlyOneArgument()
                                             .With(name: "apiKey"))),
                Create.Command("locals",
                               "Clears or lists local NuGet resources such as http requests cache, packages cache or machine-wide global packages folder.",
                               Accept.AnyOneOf(@"all",
                                               @"http-cache",
                                               @"global-packages",
                                               @"temp")
                               .With(description: "Cache Location(s)  Specifies the cache location(s) to list or clear."),
                               CommonOptions.HelpOption(),
                               Create.Option("--force-english-output",
                                             "Forces the application to run using an invariant, English-based culture."),
                               Create.Option("-c|--clear", "Clear the selected local resources or cache location(s)."),
                               Create.Option("-l|--list", "List the selected local resources or cache location(s).")),
                Create.Command("push",
                               "Pushes a package to the server and publishes it.",
                               CommonOptions.HelpOption(),
                               Create.Option("--force-english-output",
                                             "Forces the application to run using an invariant, English-based culture."),
                               Create.Option("-s|--source",
                                             "Specifies the server URL",
                                             Accept.ExactlyOneArgument()
                                             .With(name: "source")),
                               Create.Option("-ss|--symbol-source",
                                             "Specifies the symbol server URL. If not specified, nuget.smbsrc.net is used when pushing to nuget.org.",
                                             Accept.ExactlyOneArgument()
                                             .With(name: "source")),
                               Create.Option("-t|--timeout",
                                             "Specifies the timeout for pushing to a server in seconds. Defaults to 300 seconds (5 minutes).",
                                             Accept.ExactlyOneArgument()
                                             .With(name: "timeout")),
                               Create.Option("-k|--api-key", "The API key for the server.",
                                             Accept.ExactlyOneArgument()
                                             .With(name: "apiKey")),
                               Create.Option("-sk|--symbol-api-key", "The API key for the symbol server.",
                                             Accept.ExactlyOneArgument()
                                             .With(name: "apiKey")),
                               Create.Option("-d|--disable-buffering",
                                             "Disable buffering when pushing to an HTTP(S) server to decrease memory usage."),
                               Create.Option("-n|--no-symbols",
                                             "If a symbols package exists, it will not be pushed to a symbols server.")));