Esempio n. 1
0
 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 => $"/p: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 => $"/p:TargetManifestFiles={string.Join("%3B", o.Arguments)}")),
     Create.Option(
         "--self-contained",
         LocalizableStrings.SelfContainedOptionDescription,
         Accept.ZeroOrOneArgument()
         .WithSuggestionsFrom("true", "false")
         .ForwardAsSingle(o =>
 {
     string value = o.Arguments.Any() ? o.Arguments.Single() : "true";
     return($"/p:SelfContained={value}");
 })),
     CommonOptions.NoRestoreOption(),
     CommonOptions.VerbosityOption());
Esempio n. 2
0
 public static Command SlnRemove() =>
 Create.Command("remove",
                LocalizableStrings.RemoveAppFullName,
                Accept.OneOrMoreArguments(o => CommonLocalizableStrings.SpecifyAtLeastOneProjectToRemove)
                .With(name: "args",
                      description: LocalizableStrings.RemoveSubcommandHelpText),
                CommonOptions.HelpOption());
Esempio n. 3
0
 public static Command ListPackageReferences() => Create.Command(
     "package",
     LocalizableStrings.AppFullName,
     Accept.ZeroOrOneArgument(),
     CommonOptions.HelpOption(),
     Create.Option("--outdated",
                   LocalizableStrings.CmdOutdatedDescription),
     Create.Option("--framework",
                   LocalizableStrings.CmdFrameworkDescription,
                   Accept.OneOrMoreArguments()
                   .With(name: LocalizableStrings.CmdFramework)
                   .ForwardAsSingle(o => $"--framework {string.Join("%3B", o.Arguments)}")),
     Create.Option("--include-transitive",
                   LocalizableStrings.CmdTransitiveDescription),
     Create.Option("--include-prerelease",
                   LocalizableStrings.CmdPrereleaseDescription),
     Create.Option("--highest-patch",
                   LocalizableStrings.CmdHighestPatchDescription),
     Create.Option("--highest-minor",
                   LocalizableStrings.CmdHighestMinorDescription),
     Create.Option("--config",
                   LocalizableStrings.CmdConfigDescription,
                   Accept.ExactlyOneArgument()
                   .With(name: LocalizableStrings.CmdConfig)
                   .ForwardAsSingle(o => $"--config {o.Arguments.Single()}")),
     Create.Option("--source",
                   LocalizableStrings.CmdSourceDescription,
                   Accept.OneOrMoreArguments()
                   .With(name: LocalizableStrings.CmdSource)
                   .ForwardAsSingle(o => $"--source {string.Join("%3B", o.Arguments)}")));
Esempio n. 4
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)),
                           CommonOptions.HelpOption(),
                           CommonOptions.VerbosityOption()));
 }
Esempio n. 5
0
 public static Command SlnAdd() =>
 Create.Command("add",
                LocalizableStrings.AddAppFullName,
                Accept.OneOrMoreArguments(o => CommonLocalizableStrings.SpecifyAtLeastOneProjectToAdd)
                .With(name: LocalizableStrings.AddProjectPathArgumentName,
                      description: LocalizableStrings.AddProjectPathArgumentDescription),
                CommonOptions.HelpOption());
Esempio n. 6
0
 public static Command ToolRestore()
 {
     return(Create.Command(
                "restore",
                LocalizableStrings.CommandDescription,
                Accept.NoArguments(),
                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(
                    "--tool-manifest",
                    LocalizableStrings.ManifestPathOptionDescription,
                    Accept.ZeroOrOneArgument()
                    .With(name: LocalizableStrings.ManifestPathOptionName)),
                ToolCommandRestorePassThroughOptions.DisableParallelOption(),
                ToolCommandRestorePassThroughOptions.IgnoreFailedSourcesOption(),
                ToolCommandRestorePassThroughOptions.NoCacheOption(),
                ToolCommandRestorePassThroughOptions.InteractiveRestoreOption(),
                CommonOptions.HelpOption(),
                CommonOptions.VerbosityOption()));
 }
Esempio n. 7
0
 private static Option[] ImplicitRestoreOptions(bool showHelp = false, bool useShortOptions = false)
 {
     return(new Option[] {
         Create.Option(
             useShortOptions ? "-s|--source" : "--source",
             showHelp ? LocalizableStrings.CmdSourceOptionDescription : string.Empty,
             Accept.OneOrMoreArguments()
             .With(name: LocalizableStrings.CmdSourceOption)
             .ForwardAsSingle(o => $"-property:RestoreSources={string.Join("%3B", o.Arguments)}")),
         Create.Option(
             useShortOptions ? "-r|--runtime" : "--runtime",
             LocalizableStrings.CmdRuntimeOptionDescription,
             Accept.OneOrMoreArguments()
             .WithSuggestionsFrom(_ => Suggest.RunTimesFromProjectFile())
             .With(name: LocalizableStrings.CmdRuntimeOption)
             .ForwardAsSingle(o => $"-property:RuntimeIdentifiers={string.Join("%3B", o.Arguments)}")),
         CommonOptions.CurrentRuntimeOption(LocalizableStrings.CmdCurrentRuntimeOptionDescription),
         Create.Option(
             "--packages",
             showHelp ? LocalizableStrings.CmdPackagesOptionDescription : string.Empty,
             Accept.ExactlyOneArgument()
             .With(name: LocalizableStrings.CmdPackagesOption)
             .ForwardAsSingle(o => $"-property:RestorePackagesPath={CommandDirectoryContext.GetFullPath(o.Arguments.Single())}")),
         Create.Option(
             "--disable-parallel",
             showHelp ? LocalizableStrings.CmdDisableParallelOptionDescription : string.Empty,
             Accept.NoArguments()
             .ForwardAs("-property:RestoreDisableParallel=true")),
         Create.Option(
             "--configfile",
             showHelp ? LocalizableStrings.CmdConfigFileOptionDescription : string.Empty,
             Accept.ExactlyOneArgument()
             .With(name: LocalizableStrings.CmdConfigFileOption)
             .ForwardAsSingle(o => $"-property:RestoreConfigFile={CommandDirectoryContext.GetFullPath(o.Arguments.Single())}")),
         Create.Option(
             "--no-cache",
             showHelp ? LocalizableStrings.CmdNoCacheOptionDescription : string.Empty,
             Accept.NoArguments()
             .ForwardAs("-property:RestoreNoCache=true")),
         Create.Option(
             "--ignore-failed-sources",
             showHelp ? LocalizableStrings.CmdIgnoreFailedSourcesOptionDescription : string.Empty,
             Accept.NoArguments()
             .ForwardAs("-property:RestoreIgnoreFailedSources=true")),
         Create.Option(
             "--no-dependencies",
             LocalizableStrings.CmdNoDependenciesOptionDescription,
             Accept.NoArguments()
             .ForwardAs("-property:RestoreRecursive=false")),
         Create.Option(
             useShortOptions ? "-f|--force" : "--force",
             LocalizableStrings.CmdForceRestoreOptionDescription,
             Accept.NoArguments()
             .ForwardAs("-property:RestoreForce=true"))
     });
 }
Esempio n. 8
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());
 public static Command Restore() =>
 Create.Command(
     "restore",
     LocalizableStrings.AppFullName,
     Accept.ZeroOrMoreArguments(),
     CommonOptions.HelpOption(),
     Create.Option(
         "-s|--source",
         LocalizableStrings.CmdSourceOptionDescription,
         Accept.OneOrMoreArguments()
         .With(name: LocalizableStrings.CmdSourceOption)
         .ForwardAsSingle(o => $"/p:RestoreSources={string.Join("%3B", o.Arguments)}")),
     Create.Option(
         "-r|--runtime",
         LocalizableStrings.CmdRuntimeOptionDescription,
         Accept.OneOrMoreArguments()
         .WithSuggestionsFrom(_ => Suggest.RunTimesFromProjectFile())
         .With(name: LocalizableStrings.CmdRuntimeOption)
         .ForwardAsSingle(o => $"/p:RuntimeIdentifiers={string.Join("%3B", o.Arguments)}")),
     Create.Option(
         "--packages",
         LocalizableStrings.CmdPackagesOptionDescription,
         Accept.ExactlyOneArgument()
         .With(name: LocalizableStrings.CmdPackagesOption)
         .ForwardAsSingle(o => $"/p:RestorePackagesPath={o.Arguments.Single()}")),
     Create.Option(
         "--disable-parallel",
         LocalizableStrings.CmdDisableParallelOptionDescription,
         Accept.NoArguments()
         .ForwardAs("/p:RestoreDisableParallel=true")),
     Create.Option(
         "--configfile",
         LocalizableStrings.CmdConfigFileOptionDescription,
         Accept.ExactlyOneArgument()
         .With(name: LocalizableStrings.CmdConfigFileOption)
         .ForwardAsSingle(o => $"/p:RestoreConfigFile={o.Arguments.Single()}")),
     Create.Option(
         "--no-cache",
         LocalizableStrings.CmdNoCacheOptionDescription,
         Accept.NoArguments()
         .ForwardAs("/p:RestoreNoCache=true")),
     Create.Option(
         "--ignore-failed-sources",
         LocalizableStrings.CmdIgnoreFailedSourcesOptionDescription,
         Accept.NoArguments()
         .ForwardAs("/p:RestoreIgnoreFailedSources=true")),
     Create.Option(
         "--no-dependencies",
         LocalizableStrings.CmdNoDependenciesOptionDescription,
         Accept.NoArguments()
         .ForwardAs("/p:RestoreRecursive=false")),
     CommonOptions.VerbosityOption());
Esempio n. 10
0
 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|--{ToolAppliedOption.GlobalOption}",
                               LocalizableStrings.GlobalOptionDescription,
                               Accept.NoArguments()),
                           Create.Option(
                               $"--{ToolAppliedOption.LocalOption}",
                               LocalizableStrings.LocalOptionDescription,
                               Accept.NoArguments()),
                           Create.Option(
                               $"--{ToolAppliedOption.ToolPathOption}",
                               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(
                               $"--{ToolAppliedOption.ToolManifest}",
                               LocalizableStrings.ManifestPathOptionDescription,
                               Accept.ZeroOrOneArgument()
                               .With(name: LocalizableStrings.ManifestPathOptionName)),
                           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()));
 }
Esempio n. 11
0
 public static Command Publish() =>
 CreateWithRestoreOptions.Command(
     "publish",
     LocalizableStrings.AppDescription,
     Accept.ZeroOrMoreArguments()
     .With(name: CommonLocalizableStrings.SolutionOrProjectArgumentName,
           description: CommonLocalizableStrings.SolutionOrProjectArgumentDescription),
     CommonOptions.HelpOption(),
     Create.Option(
         "-o|--output",
         LocalizableStrings.OutputOptionDescription,
         Accept.ExactlyOneArgument()
         .With(name: LocalizableStrings.OutputOption)
         .ForwardAsSingle(o => $"-property:PublishDir={CommandDirectoryContext.GetFullPath(o.Arguments.Single())}")),
     CommonOptions.FrameworkOption(LocalizableStrings.FrameworkOptionDescription),
     CommonOptions.RuntimeOption(LocalizableStrings.RuntimeOptionDescription),
     CommonOptions.ConfigurationOption(LocalizableStrings.ConfigurationOptionDescription),
     CommonOptions.VersionSuffixOption(),
     Create.Option(
         "--manifest",
         LocalizableStrings.ManifestOptionDescription,
         Accept.OneOrMoreArguments()
         .With(name: LocalizableStrings.ManifestOption)
         .ForwardAsSingle(o => $"-property:TargetManifestFiles={string.Join("%3B", o.Arguments.Select(CommandDirectoryContext.GetFullPath))}")),
     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}");
 })),
     Create.Option(
         "--no-self-contained",
         LocalizableStrings.NoSelfContainedOptionDescription,
         Accept.NoArguments().ForwardAs("-property:SelfContained=false")),
     Create.Option(
         "--nologo",
         LocalizableStrings.CmdNoLogo,
         Accept.NoArguments()
         .ForwardAs("-nologo")),
     CommonOptions.InteractiveMsBuildForwardOption(),
     CommonOptions.NoRestoreOption(),
     CommonOptions.VerbosityOption());
Esempio n. 12
0
 public static Command AddProjectReference()
 {
     return(Create.Command(
                "reference",
                LocalizableStrings.AppFullName,
                Accept.OneOrMoreArguments()
                .With(name: LocalizableStrings.ProjectPathArgumentName,
                      description: LocalizableStrings.ProjectPathArgumentDescription),
                CommonOptions.HelpOption(),
                Create.Option("-f|--framework", LocalizableStrings.CmdFrameworkDescription,
                              Accept.ExactlyOneArgument()
                              .WithSuggestionsFrom(_ => Suggest.TargetFrameworksFromProjectFile())
                              .With(name: Tools.Add.PackageReference.LocalizableStrings.CmdFramework))));
 }
 public static Command RemoveReference() =>
 Create.Command(
     "reference",
     LocalizableStrings.AppFullName,
     Accept
     .OneOrMoreArguments()
     .WithSuggestionsFrom(_ => Suggest.ProjectReferencesFromProjectFile())
     .With(name: LocalizableStrings.ProjectPathArgumentName,
           description: LocalizableStrings.ProjectPathArgumentDescription),
     CommonOptions.HelpOption(),
     Create.Option(
         "-f|--framework",
         LocalizableStrings.CmdFrameworkDescription,
         Accept.ExactlyOneArgument()
         .With(name: CommonLocalizableStrings.CmdFramework)));
Esempio n. 14
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),
         Create.Option("--skip-duplicate", Parser.CompletionOnlyDescription)
         ));
Esempio n. 15
0
        public void When_one_or_more_arguments_are_expected_and_none_are_provided_then_Value_returns_empty()
        {
            var command = Command("the-command", "",
                                  Option("-x", "", Accept.OneOrMoreArguments()));

            var result = command.Parse("the-command -x");

            var value = result["the-command"]["x"].Value();

            value.Should().BeAssignableTo <IReadOnlyCollection <string> >();

            var values = (IReadOnlyCollection <string>)value;

            values
            .Should()
            .BeEmpty();
        }
 public static Command ListPackageReferences() => Create.Command(
     "package",
     LocalizableStrings.AppFullName,
     Accept.NoArguments(),
     CommonOptions.HelpOption(),
     Create.Option("--outdated",
                   LocalizableStrings.CmdOutdatedDescription,
                   Accept.NoArguments().ForwardAs("--outdated")),
     Create.Option("--deprecated",
                   LocalizableStrings.CmdDeprecatedDescription,
                   Accept.NoArguments().ForwardAs("--deprecated")),
     Create.Option("--vulnerable",
                   LocalizableStrings.CmdVulnerableDescription,
                   Accept.NoArguments().ForwardAs("--vulnerable")),
     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")),
     CommonOptions.VerbosityOption(o => $"--verbosity:{o.Arguments.Single()}"));
 internal static Command Migrate() =>
 Create.Command("migrate",
                "Migrate projects to modern Visual Studio CPS format (non-interactive)",
                ItemsArgument,
                Create.Option("-n|--no-backup",
                              "Skip moving project.json, global.json, and *.xproj to a `Backup` directory after successful migration."),
                ForceOption,
                KeepAssemblyInfoOption,
                TargetFrameworksOption,
                Create.Option("-o|--old-output-path",
                              "Preserve legacy behavior by not creating a subfolder with the target framework in the output path."),
                Create.Option(
                    "-ft|--force-transformations",
                    "Force execution of transformations despite project conversion state by their specified names. " +
                    "Specify multiple times for multiple enforced transformations.",
                    Accept.OneOrMoreArguments()
                    .With("Transformation names to enforce execution", "names")),
                HelpOption());
Esempio n. 18
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. 19
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());
        public static Command Test() =>
        Create.Command(
            "test",
            LocalizableStrings.AppFullName,
            Accept.ZeroOrMoreArguments()
            .With(name: LocalizableStrings.CmdArgProject,
                  description: LocalizableStrings.CmdArgDescription),
            false,
            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()}")),
            Create.Option(
                "--collect",
                LocalizableStrings.cmdCollectDescription,
                Accept.OneOrMoreArguments()
                .With(name: LocalizableStrings.cmdCollectFriendlyName)
                .ForwardAsSingle(o => $"/p:VSTestCollect=\"{string.Join(";", o.Arguments)}\"")),
            Create.Option(
                "--blame",
                LocalizableStrings.CmdBlameDescription,
                Accept.NoArguments()
                .ForwardAsSingle(o => "/p:VSTestBlame=true")),
            CommonOptions.NoRestoreOption(),
            CommonOptions.VerbosityOption());
Esempio n. 21
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. 22
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. 23
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());