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 ;
2017-04-21 16:56:34 -07:00
using Microsoft.DotNet.Tools ;
2017-03-06 11:57:19 -08:00
namespace Microsoft.DotNet.Cli
{
internal static class CommonOptions
{
public static Option HelpOption ( ) = >
2017-03-06 20:53:26 -08:00
Create . Option (
"-h|--help" ,
2017-05-09 21:05:09 -07:00
CommonLocalizableStrings . ShowHelpDescription ,
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-04-21 16:56:34 -07:00
CommonLocalizableStrings . VerbosityOptionDescription ,
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-16 13:22:08 -07:00
. ForwardAsSingle ( o = > $"/verbosity:{o.Arguments.Single()}" ) ) ;
2017-03-09 16:11:58 -08:00
public static Option FrameworkOption ( ) = >
Create . Option (
"-f|--framework" ,
2017-04-21 16:56:34 -07:00
CommonLocalizableStrings . FrameworkOptionDescription ,
2017-03-10 17:52:40 -08:00
Accept . ExactlyOneArgument ( )
2017-03-09 16:11:58 -08:00
. WithSuggestionsFrom ( _ = > Suggest . TargetFrameworksFromProjectFile ( ) )
. With ( name : "FRAMEWORK" )
2017-03-16 13:22:08 -07:00
. ForwardAsSingle ( o = > $"/p:TargetFramework={o.Arguments.Single()}" ) ) ;
2017-03-09 16:11:58 -08:00
public static Option RuntimeOption ( ) = >
Create . Option (
"-r|--runtime" ,
2017-04-21 16:56:34 -07:00
CommonLocalizableStrings . RuntimeOptionDescription ,
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" )
2017-03-16 13:22:08 -07:00
. ForwardAsSingle ( o = > $"/p:RuntimeIdentifier={o.Arguments.Single()}" ) ) ;
2017-03-09 16:11:58 -08:00
public static Option ConfigurationOption ( ) = >
Create . Option (
2017-04-21 16:56:34 -07:00
"-c|--configuration" ,
CommonLocalizableStrings . ConfigurationOptionDescription ,
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-16 13:22:08 -07:00
. ForwardAsSingle ( 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" ,
2017-04-21 16:56:34 -07:00
CommonLocalizableStrings . CmdVersionSuffixDescription ,
2017-03-10 17:52:40 -08:00
Accept . ExactlyOneArgument ( )
2017-03-10 01:10:23 -08:00
. With ( name : "VERSION_SUFFIX" )
2017-03-16 13:22:08 -07:00
. ForwardAsSingle ( o = > $"/p:VersionSuffix={o.Arguments.Single()}" ) ) ;
2017-03-10 01:10:23 -08:00
2017-03-06 11:57:19 -08:00
public static ArgumentsRule DefaultToCurrentDirectory ( this ArgumentsRule rule ) = >
rule . With ( defaultValue : ( ) = > PathUtility . EnsureTrailingSlash ( Directory . GetCurrentDirectory ( ) ) ) ;
}
}