dotnet-installer/src/dotnet/CommonOptions.cs

67 lines
3.1 KiB
C#
Raw Normal View History

using System.IO;
using System.Linq;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Tools.Common;
namespace Microsoft.DotNet.Cli
{
internal static class CommonOptions
{
public static Option HelpOption() =>
2017-03-06 20:53:26 -08:00
Create.Option(
"-h|--help",
"Show help information",
2017-03-10 17:11:19 -08:00
Accept.NoArguments(),
2017-03-06 20:53:26 -08:00
materialize: o => o.Option.Command().HelpView());
public static Option VerbosityOption() =>
2017-03-06 20:53:26 -08:00
Create.Option(
"-v|--verbosity",
2017-03-09 16:11:58 -08:00
"Set the verbosity level of the command. Allowed values are q[uiet],<2C>m[inimal],<2C>n[ormal],<2C>d[etailed], and<6E>diag[nostic]",
Accept.AnyOneOf(
"q", "quiet",
2017-03-06 20:53:26 -08:00
"m", "minimal",
"n", "normal",
2017-03-09 13:57:37 -08:00
"d", "detailed",
"diag", "diagnostic")
.ForwardAs(o => $"/verbosity:{o.Arguments.Single()}"));
2017-03-09 16:11:58 -08:00
public static Option FrameworkOption() =>
Create.Option(
"-f|--framework",
"Target framework to publish for. The target framework has to be specified in the project file.",
2017-03-10 17:52:40 -08:00
Accept.ExactlyOneArgument()
2017-03-09 16:11:58 -08:00
.WithSuggestionsFrom(_ => Suggest.TargetFrameworksFromProjectFile())
.With(name: "FRAMEWORK")
.ForwardAs(o => $"/p:TargetFramework={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.",
2017-03-10 17:52:40 -08:00
Accept.ExactlyOneArgument()
2017-03-09 16:11:58 -08:00
.WithSuggestionsFrom(_ => Suggest.RunTimesFromProjectFile())
.With(name: "RUNTIME_IDENTIFIER")
.ForwardAs(o => $"/p:RuntimeIdentifier={o.Arguments.Single()}"));
public static Option ConfigurationOption() =>
Create.Option(
"-c|--configuration",
"Configuration to use for building the project. Default for most projects is \"Debug\".",
2017-03-10 17:52:40 -08:00
Accept.ExactlyOneArgument()
2017-03-09 16:11:58 -08:00
.With(name: "CONFIGURATION")
.WithSuggestionsFrom("DEBUG", "RELEASE")
2017-03-09 16:13:19 -08:00
.ForwardAs(o => $"/p:Configuration={o.Arguments.Single()}"));
2017-03-10 01:10:23 -08:00
public static Option VersionSuffixOption() =>
Create.Option(
"--version-suffix",
"Defines the value for the $(VersionSuffix) property in the project.",
2017-03-10 17:52:40 -08:00
Accept.ExactlyOneArgument()
2017-03-10 01:10:23 -08:00
.With(name: "VERSION_SUFFIX")
.ForwardAs(o => $"/p:VersionSuffix={o.Arguments.Single()}"));
public static ArgumentsRule DefaultToCurrentDirectory(this ArgumentsRule rule) =>
rule.With(defaultValue: () => PathUtility.EnsureTrailingSlash(Directory.GetCurrentDirectory()));
}
}