2017-03-12 15:06:34 -07:00
|
|
|
using System;
|
2017-03-06 11:57:19 -08:00
|
|
|
using System.IO;
|
2017-03-09 09:14:55 -08:00
|
|
|
using System.Linq;
|
2017-03-06 11:57:19 -08:00
|
|
|
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());
|
2017-03-06 11:57:19 -08:00
|
|
|
|
|
|
|
public static Option VerbosityOption() =>
|
2017-03-06 20:53:26 -08:00
|
|
|
Create.Option(
|
|
|
|
"-v|--verbosity",
|
2017-03-14 10:33:58 -07:00
|
|
|
"Set the verbosity level of the command. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]",
|
2017-03-09 07:35:06 -08:00
|
|
|
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")
|
2017-03-09 09:14:55 -08:00
|
|
|
.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-06 11:57:19 -08:00
|
|
|
|
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()}"));
|
|
|
|
|
2017-03-06 11:57:19 -08:00
|
|
|
public static ArgumentsRule DefaultToCurrentDirectory(this ArgumentsRule rule) =>
|
|
|
|
rule.With(defaultValue: () => PathUtility.EnsureTrailingSlash(Directory.GetCurrentDirectory()));
|
|
|
|
}
|
|
|
|
}
|