Exemplo n.º 1
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"))
     });
 }
Exemplo n.º 2
0
        public static Command GetCommand()
        {
            var command = new Command("store", LocalizableStrings.AppDescription);

            command.AddArgument(Argument);
            command.AddOption(ManifestOption);
            command.AddOption(FrameworkVersionOption);
            command.AddOption(OutputOption);
            command.AddOption(WorkingDirOption);
            command.AddOption(SkipOptimizationOption);
            command.AddOption(SkipSymbolsOption);
            command.AddOption(CommonOptions.FrameworkOption(LocalizableStrings.FrameworkOptionDescription));
            command.AddOption(CommonOptions.RuntimeOption(LocalizableStrings.RuntimeOptionDescription));
            command.AddOption(CommonOptions.VerbosityOption());
            command.AddOption(CommonOptions.CurrentRuntimeOption(LocalizableStrings.CurrentRuntimeOptionDescription));

            return(command);
        }
Exemplo n.º 3
0
        private static Command ConstructCommand()
        {
            var command = new DocumentedCommand("store", DocsLink, LocalizableStrings.AppDescription);

            command.AddArgument(Argument);
            command.AddOption(ManifestOption);
            command.AddOption(FrameworkVersionOption);
            command.AddOption(OutputOption);
            command.AddOption(WorkingDirOption);
            command.AddOption(SkipOptimizationOption);
            command.AddOption(SkipSymbolsOption);
            command.AddOption(CommonOptions.FrameworkOption(LocalizableStrings.FrameworkOptionDescription));
            command.AddOption(CommonOptions.RuntimeOption.WithHelpDescription(command, LocalizableStrings.RuntimeOptionDescription));
            command.AddOption(CommonOptions.VerbosityOption);
            command.AddOption(CommonOptions.CurrentRuntimeOption(LocalizableStrings.CurrentRuntimeOptionDescription));

            command.SetHandler(StoreCommand.Run);

            return(command);
        }
Exemplo n.º 4
0
        private static Option[] ImplicitRestoreOptions(bool showHelp, bool useShortOptions, bool includeRuntimeOption, bool includeNoDependenciesOption)
        {
            var options = new Option[] {
                new ForwardedOption <IEnumerable <string> >(
                    useShortOptions ? new string[] { "-s", "--source" }  : new string[] { "--source" },
                    showHelp ? LocalizableStrings.CmdSourceOptionDescription : string.Empty)
                {
                    ArgumentHelpName = LocalizableStrings.CmdSourceOption,
                    IsHidden         = !showHelp
                }.ForwardAsSingle(o => $"-property:RestoreSources={string.Join("%3B", o)}")
                .AllowSingleArgPerToken(),
                new ForwardedOption <string>(
                    "--packages",
                    showHelp ? LocalizableStrings.CmdPackagesOptionDescription : string.Empty)
                {
                    ArgumentHelpName = LocalizableStrings.CmdPackagesOption,
                    IsHidden         = !showHelp
                }.ForwardAsSingle(o => $"-property:RestorePackagesPath={CommandDirectoryContext.GetFullPath(o)}"),
                CommonOptions.CurrentRuntimeOption(LocalizableStrings.CmdCurrentRuntimeOptionDescription),
                new ForwardedOption <bool>(
                    "--disable-parallel",
                    showHelp ? LocalizableStrings.CmdDisableParallelOptionDescription : string.Empty)
                {
                    IsHidden = !showHelp
                }.ForwardAs("-property:RestoreDisableParallel=true"),
                new ForwardedOption <string>(
                    "--configfile",
                    showHelp ? LocalizableStrings.CmdConfigFileOptionDescription : string.Empty)
                {
                    ArgumentHelpName = LocalizableStrings.CmdConfigFileOption,
                    IsHidden         = !showHelp
                }.ForwardAsSingle(o => $"-property:RestoreConfigFile={CommandDirectoryContext.GetFullPath(o)}"),
                new ForwardedOption <bool>(
                    "--no-cache",
                    showHelp ? LocalizableStrings.CmdNoCacheOptionDescription : string.Empty)
                {
                    IsHidden = !showHelp
                }.ForwardAs("-property:RestoreNoCache=true"),
                new ForwardedOption <bool>(
                    "--ignore-failed-sources",
                    showHelp ? LocalizableStrings.CmdIgnoreFailedSourcesOptionDescription : string.Empty)
                {
                    IsHidden = !showHelp
                }.ForwardAs("-property:RestoreIgnoreFailedSources=true"),
                new ForwardedOption <bool>(
                    useShortOptions ? new string[] { "-f", "--force" } : new string[] { "--force" },
                    LocalizableStrings.CmdForceRestoreOptionDescription)
                {
                    IsHidden = !showHelp
                }.ForwardAs("-property:RestoreForce=true"),
                CommonOptions.PropertiesOption()
            };

            if (includeRuntimeOption)
            {
                options = options.Append(
                    new ForwardedOption <IEnumerable <string> >(
                        useShortOptions ? new string[] { "-r", "--runtime" } : new string[] { "--runtime" },
                        LocalizableStrings.CmdRuntimeOptionDescription)
                {
                    ArgumentHelpName = LocalizableStrings.CmdRuntimeOption,
                    IsHidden         = !showHelp
                }.ForwardAsSingle(o => $"-property:RuntimeIdentifiers={string.Join("%3B", o)}")
                    .AllowSingleArgPerToken()
                    .AddSuggestions(Suggest.RunTimesFromProjectFile())
                    ).ToArray();
            }

            if (includeNoDependenciesOption)
            {
                options = options.Append(
                    new ForwardedOption <bool>(
                        "--no-dependencies",
                        LocalizableStrings.CmdNoDependenciesOptionDescription)
                {
                    IsHidden = !showHelp
                }.ForwardAs("-property:RestoreRecursive=false")
                    ).ToArray();
            }

            return(options);
        }
Exemplo n.º 5
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),
            CommonOptions.CurrentRuntimeOption(LocalizableStrings.CurrentRuntimeOptionDescription),
            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());