public static Option RuntimeOption() => Create.Option( "-r|--runtime", CommonLocalizableStrings.RuntimeOptionDescription, Accept.ExactlyOneArgument() .WithSuggestionsFrom(_ => Suggest.RunTimesFromProjectFile()) .With(name: "RUNTIME_IDENTIFIER") .ForwardAsSingle(o => $"-property:RuntimeIdentifier={o.Arguments.Single()}"));
public static Option ConfigurationOption(string description) => Create.Option( "-c|--configuration", description, Accept.ExactlyOneArgument() .With(name: CommonLocalizableStrings.ConfigurationArgumentName) .WithSuggestionsFrom(_ => Suggest.ConfigurationsFromProjectFileOrDefaults()) .ForwardAsSingle(o => $"-property:Configuration={o.Arguments.Single()}"));
public static Option FrameworkOption() => Create.Option( "-f|--framework", CommonLocalizableStrings.FrameworkOptionDescription, Accept.ExactlyOneArgument() .WithSuggestionsFrom(_ => Suggest.TargetFrameworksFromProjectFile()) .With(name: "FRAMEWORK") .ForwardAsSingle(o => $"-property:TargetFramework={o.Arguments.Single()}"));
public static Option FrameworkOption() => Create.Option( "-f|--framework", "Target framework to publish for. The target framework has to be specified in the project file.", Accept.ExactlyOneArgument() .WithSuggestionsFrom(_ => Suggest.TargetFrameworksFromProjectFile()) .With(name: "FRAMEWORK") .ForwardAsSingle(o => $"/p:TargetFramework={o.Arguments.Single()}"));
public static Option RuntimeOption(string description, bool withShortOption = true) => Create.Option( withShortOption ? "-r|--runtime" : "--runtime", description, Accept.ExactlyOneArgument() .WithSuggestionsFrom(_ => Suggest.RunTimesFromProjectFile()) .With(name: CommonLocalizableStrings.RuntimeIdentifierArgumentName) .ForwardAsSingle(o => $"-property:RuntimeIdentifier={o.Arguments.Single()}"));
public static Option RuntimeOption() => Create.Option( "-r|--runtime", "Publish the project for a given runtime. This is used when creating self-contained deployment. Default is to publish a framework-dependent app.", Accept.ExactlyOneArgument() .WithSuggestionsFrom(_ => Suggest.RunTimesFromProjectFile()) .With(name: "RUNTIME_IDENTIFIER") .ForwardAsSingle(o => $"/p:RuntimeIdentifier={o.Arguments.Single()}"));
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")) }); }
public static Option FrameworkOption(string description) => new Option <string>( new string[] { "-f", "--framework" }, description) { Argument = new Argument <string>(CommonLocalizableStrings.FrameworkArgumentName) .AddSuggestions(Suggest.TargetFrameworksFromProjectFile().ToArray()) }.ForwardAsSingle(o => $"-property:TargetFramework={o}");
public static Option ConfigurationOption(string description) => new Option <string>( new string[] { "-c", "--configuration" }, description) { Argument = new Argument <string>(CommonLocalizableStrings.ConfigurationArgumentName) .AddSuggestions(Suggest.ConfigurationsFromProjectFileOrDefaults().ToArray()) }.ForwardAsSingle(o => $"-property:Configuration={o}");
public static Option <string> FrameworkOption(string description) => new ForwardedOption <string>( new string[] { "-f", "--framework" }, description) { ArgumentHelpName = CommonLocalizableStrings.FrameworkArgumentName }.ForwardAsSingle(o => $"-property:TargetFramework={o}") .AddSuggestions(Suggest.TargetFrameworksFromProjectFile());
public static Option <string> ConfigurationOption(string description) => new ForwardedOption <string>( new string[] { "-c", "--configuration" }, description) { ArgumentHelpName = CommonLocalizableStrings.ConfigurationArgumentName }.ForwardAsSingle(o => $"-property:Configuration={o}") .AddSuggestions(Suggest.ConfigurationsFromProjectFileOrDefaults());
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());
public static Option <string> RuntimeOption(string description, bool withShortOption = true) => new ForwardedOption <string>( withShortOption ? new string[] { "-r", "--runtime" } : new string[] { "--runtime" }, description) { ArgumentHelpName = CommonLocalizableStrings.RuntimeIdentifierArgumentName }.ForwardAsMany(o => new string[] { $"-property:RuntimeIdentifier={o}", "-property:_CommandLineDefinedRuntimeIdentifier=true" }) .AddSuggestions(Suggest.RunTimesFromProjectFile());
public static Option RuntimeOption(string description, bool withShortOption = true) => new Option <string>( withShortOption ? new string[] { "-r", "--runtime" } : new string[] { "--runtime" }, description) { Argument = new Argument <string>(CommonLocalizableStrings.RuntimeIdentifierArgumentName) .AddSuggestions(Suggest.RunTimesFromProjectFile().ToArray()) }.ForwardAsSingle(o => $"-property:RuntimeIdentifier={o}");
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)));
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); }