public static Option VerbosityOption() => Create.Option( "-v|--verbosity", CommonLocalizableStrings.VerbosityOptionDescription, Accept.AnyOneOf( "q", "quiet", "m", "minimal", "n", "normal", "d", "detailed", "diag", "diagnostic") .ForwardAsSingle(o => $"-verbosity:{o.Arguments.Single()}"));
public static Option VerbosityOption() => Create.Option( "-v|--verbosity", "Set the verbosity level of the command. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]", Accept.AnyOneOf( "q", "quiet", "m", "minimal", "n", "normal", "d", "detailed", "diag", "diagnostic") .ForwardAsSingle(o => $"/verbosity:{o.Arguments.Single()}"));
public static Option VerbosityOption(Func <AppliedOption, string> format) => Create.Option( "-v|--verbosity", CommonLocalizableStrings.VerbosityOptionDescription, Accept.AnyOneOf( "q", "quiet", "m", "minimal", "n", "normal", "d", "detailed", "diag", "diagnostic") .With(name: CommonLocalizableStrings.LevelArgumentName) .ForwardAsSingle(format));
internal static Option VerbosityOption() => Create.Option("-v|--verbosity", // ReSharper disable StringLiteralTypo "Set the verbosity level of the command. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]", // ReSharper restore StringLiteralTypo Accept.AnyOneOf("q", "quiet", "m", "minimal", "n", "normal", "d", "detailed", // ReSharper disable once StringLiteralTypo "diag", "diagnostic") .With(name: "LEVEL"));
public void Parse_result_diagram_helps_explain_partial_parse_operation() { var parser = new Parser( Create.Command("command", "", Create.Option("-x", "", arguments: Accept.AnyOneOf("arg1", "arg2", "arg3")))); var result = parser.Parse("command -x ar"); result.Diagram() .Should() .Be("[ command [ -x ] ] ???--> ar"); }
public static Command NuGet() => Create.Command( "nuget", Parser.CompletionOnlyDescription, Create.Option("-h|--help", Parser.CompletionOnlyDescription), Create.Option("--version", Parser.CompletionOnlyDescription), Create.Option("-v|--verbosity", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()), Create.Command( "delete", Parser.CompletionOnlyDescription, Accept.OneOrMoreArguments(), Create.Option("-h|--help", Parser.CompletionOnlyDescription), Create.Option("--force-english-output", Parser.CompletionOnlyDescription), Create.Option("-s|--source", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()), Create.Option("--non-interactive", Parser.CompletionOnlyDescription), Create.Option("-k|--api-key", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()), Create.Option("--no-service-endpoint", Parser.CompletionOnlyDescription), Create.Option("--interactive", Parser.CompletionOnlyDescription)), Create.Command( "locals", Parser.CompletionOnlyDescription, Accept.AnyOneOf( "all", "http-cache", "global-packages", "plugins-cache", "temp"), Create.Option("-h|--help", Parser.CompletionOnlyDescription), Create.Option("--force-english-output", Parser.CompletionOnlyDescription), Create.Option("-c|--clear", Parser.CompletionOnlyDescription), Create.Option("-l|--list", Parser.CompletionOnlyDescription)), Create.Command( "push", Parser.CompletionOnlyDescription, Accept.OneOrMoreArguments(), Create.Option("-h|--help", Parser.CompletionOnlyDescription), Create.Option("--force-english-output", Parser.CompletionOnlyDescription), Create.Option("-s|--source", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()), Create.Option("-ss|--symbol-source", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()), Create.Option("-t|--timeout", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()), Create.Option("-k|--api-key", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()), Create.Option("-sk|--symbol-api-key", Parser.CompletionOnlyDescription, Accept.ExactlyOneArgument()), Create.Option("-d|--disable-buffering", Parser.CompletionOnlyDescription), Create.Option("-n|--no-symbols", Parser.CompletionOnlyDescription), Create.Option("--no-service-endpoint", Parser.CompletionOnlyDescription), Create.Option("--interactive", Parser.CompletionOnlyDescription), Create.Option("--skip-duplicate", Parser.CompletionOnlyDescription) ));
public static Command Test() => Create.Command( "test", LocalizableStrings.AppFullName, Accept.ZeroOrMoreArguments() .With(name: CommonLocalizableStrings.SolutionOrProjectArgumentName, description: CommonLocalizableStrings.SolutionOrProjectArgumentDescription), false, CommonOptions.HelpOption(), Create.Option( "-s|--settings", LocalizableStrings.CmdSettingsDescription, Accept.ExactlyOneArgument() .With(name: LocalizableStrings.CmdSettingsFile) .ForwardAsSingle(o => $"-property:VSTestSetting={CommandDirectoryContext.GetFullPath(o.Arguments.Single())}")), Create.Option( "-t|--list-tests", LocalizableStrings.CmdListTestsDescription, Accept.NoArguments() .ForwardAsSingle(o => "-property:VSTestListTests=true")), Create.Option( "--filter", LocalizableStrings.CmdTestCaseFilterDescription, Accept.ExactlyOneArgument() .With(name: LocalizableStrings.CmdTestCaseFilterExpression) .ForwardAsSingle(o => $"-property:VSTestTestCaseFilter={o.Arguments.Single()}")), Create.Option( "-a|--test-adapter-path", LocalizableStrings.CmdTestAdapterPathDescription, Accept.OneOrMoreArguments() .With(name: LocalizableStrings.CmdTestAdapterPath) .ForwardAsSingle(o => $"-property:VSTestTestAdapterPath=\"{string.Join(";", o.Arguments.Select(CommandDirectoryContext.GetFullPath))}\"")), Create.Option( "-l|--logger", LocalizableStrings.CmdLoggerDescription, Accept.OneOrMoreArguments() .With(name: LocalizableStrings.CmdLoggerOption) .ForwardAsSingle(o => { var loggersString = string.Join(";", GetSemiColonEscapedArgs(o.Arguments)); return($"-property:VSTestLogger=\"{loggersString}\""); })), CommonOptions.ConfigurationOption(LocalizableStrings.ConfigurationOptionDescription), CommonOptions.FrameworkOption(LocalizableStrings.FrameworkOptionDescription), CommonOptions.RuntimeOption(LocalizableStrings.RuntimeOptionDescription, withShortOption: false), Create.Option( "-o|--output", LocalizableStrings.CmdOutputDescription, Accept.ExactlyOneArgument() .With(name: LocalizableStrings.CmdOutputDir) .ForwardAsSingle(o => $"-property:OutputPath={CommandDirectoryContext.GetFullPath(o.Arguments.Single())}")), Create.Option( "-d|--diag", LocalizableStrings.CmdPathTologFileDescription, Accept.ExactlyOneArgument() .With(name: LocalizableStrings.CmdPathToLogFile) .ForwardAsSingle(o => $"-property:VSTestDiag={CommandDirectoryContext.GetFullPath(o.Arguments.Single())}")), Create.Option( "--no-build", LocalizableStrings.CmdNoBuildDescription, Accept.NoArguments() .ForwardAsSingle(o => "-property:VSTestNoBuild=true")), Create.Option( "-r|--results-directory", LocalizableStrings.CmdResultsDirectoryDescription, Accept.ExactlyOneArgument() .With(name: LocalizableStrings.CmdPathToResultsDirectory) .ForwardAsSingle(o => $"-property:VSTestResultsDirectory={CommandDirectoryContext.GetFullPath(o.Arguments.Single())}")), Create.Option( "--collect", LocalizableStrings.cmdCollectDescription, Accept.OneOrMoreArguments() .With(name: LocalizableStrings.cmdCollectFriendlyName) .ForwardAsSingle(o => $"-property:VSTestCollect=\"{string.Join(";", o.Arguments)}\"")), Create.Option( "--blame", LocalizableStrings.CmdBlameDescription, Accept.NoArguments() .ForwardAsSingle(o => "-property:VSTestBlame=true")), Create.Option( "--blame-crash", LocalizableStrings.CmdBlameCrashDescription, Accept.NoArguments() .ForwardAsSingle(o => "-property:VSTestBlameCrash=true")), Create.Option( "--blame-crash-dump-type", LocalizableStrings.CmdBlameCrashDumpTypeDescription, Accept.AnyOneOf( "full", "mini") .With(name: LocalizableStrings.CrashDumpTypeArgumentName, defaultValue: () => "full") .ForwardAsMany(o => new[] { "-property:VSTestBlameCrash=true", $"-property:VSTestBlameCrashDumpType={o.Arguments.Single()}" })), Create.Option( "--blame-crash-collect-always", LocalizableStrings.CmdBlameCrashCollectAlwaysDescription, Accept.NoArguments() .ForwardAsMany(o => new[] { "-property:VSTestBlameCrash=true", "-property:VSTestBlameCrashCollectAlways=true" })), Create.Option( "--blame-hang", LocalizableStrings.CmdBlameHangDescription, Accept.NoArguments() .ForwardAsSingle(o => "-property:VSTestBlameHang=true")), Create.Option( "--blame-hang-dump-type", LocalizableStrings.CmdBlameHangDumpTypeDescription, Accept.AnyOneOf( "full", "mini", "none") .With(name: LocalizableStrings.HangDumpTypeArgumentName, defaultValue: () => "full") .ForwardAsMany(o => new[] { "-property:VSTestBlameHang=true", $"-property:VSTestBlameHangDumpType={o.Arguments.Single()}" })), Create.Option( "--blame-hang-timeout", LocalizableStrings.CmdBlameHangTimeoutDescription, Accept.ExactlyOneArgument() .With(name: LocalizableStrings.HangTimeoutArgumentName) .ForwardAsMany(o => new[] { "-property:VSTestBlameHang=true", $"-property:VSTestBlameHangTimeout={o.Arguments.Single()}" })), Create.Option( "--nologo|/nologo", LocalizableStrings.CmdNoLogo, Accept.NoArguments() .ForwardAsSingle(o => "-property:VSTestNoLogo=nologo")), CommonOptions.NoRestoreOption(), CommonOptions.InteractiveMsBuildForwardOption(), CommonOptions.VerbosityOption());
public static Command NuGet() => Create.Command("nuget", "NuGet Command Line 4.0.0.0", CommonOptions.HelpOption(), Create.Option("--version", "Show version information"), Create.Option("-v|--verbosity", "The verbosity of logging to use. Allowed values: Debug, Verbose, Information, Minimal, Warning, Error.", Accept.ExactlyOneArgument() .With(name: "verbosity")), Create.Command("delete", "Deletes a package from the server.", Accept.ExactlyOneArgument() .With(name: "root", description: "The Package Id and version."), CommonOptions.HelpOption(), Create.Option("--force-english-output", "Forces the application to run using an invariant, English-based culture."), Create.Option("-s|--source", "Specifies the server URL", Accept.ExactlyOneArgument() .With(name: "source")), Create.Option("--non-interactive", "Do not prompt for user input or confirmations."), Create.Option("-k|--api-key", "The API key for the server.", Accept.ExactlyOneArgument() .With(name: "apiKey"))), Create.Command("locals", "Clears or lists local NuGet resources such as http requests cache, packages cache or machine-wide global packages folder.", Accept.AnyOneOf(@"all", @"http-cache", @"global-packages", @"temp") .With(description: "Cache Location(s) Specifies the cache location(s) to list or clear."), CommonOptions.HelpOption(), Create.Option("--force-english-output", "Forces the application to run using an invariant, English-based culture."), Create.Option("-c|--clear", "Clear the selected local resources or cache location(s)."), Create.Option("-l|--list", "List the selected local resources or cache location(s).")), Create.Command("push", "Pushes a package to the server and publishes it.", CommonOptions.HelpOption(), Create.Option("--force-english-output", "Forces the application to run using an invariant, English-based culture."), Create.Option("-s|--source", "Specifies the server URL", Accept.ExactlyOneArgument() .With(name: "source")), Create.Option("-ss|--symbol-source", "Specifies the symbol server URL. If not specified, nuget.smbsrc.net is used when pushing to nuget.org.", Accept.ExactlyOneArgument() .With(name: "source")), Create.Option("-t|--timeout", "Specifies the timeout for pushing to a server in seconds. Defaults to 300 seconds (5 minutes).", Accept.ExactlyOneArgument() .With(name: "timeout")), Create.Option("-k|--api-key", "The API key for the server.", Accept.ExactlyOneArgument() .With(name: "apiKey")), Create.Option("-sk|--symbol-api-key", "The API key for the symbol server.", Accept.ExactlyOneArgument() .With(name: "apiKey")), Create.Option("-d|--disable-buffering", "Disable buffering when pushing to an HTTP(S) server to decrease memory usage."), Create.Option("-n|--no-symbols", "If a symbols package exists, it will not be pushed to a symbols server.")));