2using System.Collections;
3using System.Collections.Generic;
8using Microsoft.FSharp.Core;
10using Xunit.Abstractions;
32 var arguments = args.Split(
' ');
33 object options =
null;
34 IEnumerable<Error> errors =
null;
36 .WithParsed(o => options = o)
37 .WithNotParsed(o => errors = o)
39 if (errors !=
null && errors.Any())
41 foreach (
Error e
in errors)
43 System.Console.WriteLine(e.ToString());
47 Assert.NotNull(options);
48 Assert.Equal(expectedArgType, options.GetType());
57 [InlineData(
"move -a bob", typeof(AliasedVerbOption1))]
58 [InlineData(
"mv -a bob", typeof(AliasedVerbOption1))]
59 [InlineData(
"delete -b fred", typeof(VerbNoAlias))]
62 var arguments = args.Split(
' ');
63 object options =
null;
64 IEnumerable<Error> errors =
null;
66 .WithParsed(o => options = o)
67 .WithNotParsed(o => errors = o)
69 if (errors !=
null && errors.Any())
71 foreach (
Error e
in errors)
73 System.Console.WriteLine(e.ToString());
77 Assert.NotNull(options);
78 Assert.Equal(expectedArgType, options.GetType());
88 [InlineData(
"--help",
true,
new string[]
90 "copy, cp, cpy (Default Verb) Copy some stuff",
92 "delete Delete stuff",
93 "help Display more information on a specific command.",
94 "version Display version information.",
96 [InlineData(
"help",
true,
new string[]
98 "copy, cp, cpy (Default Verb) Copy some stuff",
100 "delete Delete stuff",
101 "help Display more information on a specific command.",
102 "version Display version information.",
104 [InlineData(
"move --help",
false,
new string[]
106 "-a, --alpha Required.",
107 "--help Display this help screen.",
108 "--version Display version information.",
110 [InlineData(
"mv --help",
false,
new string[]
112 "-a, --alpha Required.",
113 "--help Display this help screen.",
114 "--version Display version information.",
116 [InlineData(
"delete --help",
false,
new string[]
118 "-b, --beta Required.",
119 "--help Display this help screen.",
120 "--version Display version information.",
124 var arguments = args.Split(
' ');
125 object options =
null;
126 IEnumerable<Error> errors =
null;
134 .WithParsed(o => options = o)
135 .WithNotParsed(o => errors = o)
138 var message =
HelpText.AutoBuild(result,
141 verbsIndex: verbsIndex
144 string helpMessage = message.
ToString();
145 var helps = helpMessage.Split(
new[] {
'\r',
'\n' }, StringSplitOptions.RemoveEmptyEntries).Skip(2).ToList<
string>();
147 expected.Length.Should().Be(helps.Count);
149 foreach (var expect
in expected)
151 helps[i].Trim().Should().Be(expect);
163 [InlineData(
"--help",
true,
new string[]
166 "delete Delete stuff",
167 "help Display more information on a specific command.",
168 "version Display version information.",
170 [InlineData(
"help",
true,
new string[]
173 "delete Delete stuff",
174 "help Display more information on a specific command.",
175 "version Display version information.",
177 [InlineData(
"move --help",
false,
new string[]
179 "-a, --alpha Required.",
180 "--help Display this help screen.",
181 "--version Display version information.",
183 [InlineData(
"mv --help",
false,
new string[]
185 "-a, --alpha Required.",
186 "--help Display this help screen.",
187 "--version Display version information.",
189 [InlineData(
"delete --help",
false,
new string[]
191 "-b, --beta Required.",
192 "--help Display this help screen.",
193 "--version Display version information.",
197 var arguments = args.Split(
' ');
198 object options =
null;
199 IEnumerable<Error> errors =
null;
206 .WithParsed(o => options = o)
207 .WithNotParsed(o => errors = o)
210 var message =
HelpText.AutoBuild(result,
213 verbsIndex: verbsIndex
216 string helpMessage = message.
ToString();
217 var helps = helpMessage.Split(
new[] {
'\r',
'\n' }, StringSplitOptions.RemoveEmptyEntries).Skip(2).ToList<
string>();
219 expected.Length.Should().Be(helps.Count);
221 foreach (var expect
in expected)
223 helps[i].Trim().Should().Be(expect);
229 aliases: new string[] {
"mv" }
233 [Option(
'a',
"alpha", Required =
true)]
234 public string Option {
get;
set; }
239 aliases: new string[] {
"cp",
"cpy" },
244 [Option(
'a',
"alpha", Required =
true)]
245 public string Option {
get;
set; }
248 [Verb(
"delete",
HelpText =
"Delete stuff")]
251 [
Option(
'b',
"beta", Required =
true)]
Provides methods to parse command line arguments.
ParserResult< object > ParseArguments(IEnumerable< string > args, params Type[] types)
Parses a string array of command line arguments for verb commands scenario, constructing the proper i...
static Parser Default
Gets the singleton instance created with basic defaults.
void Parse_option_with_aliased_verbs(string args, Type expectedArgType)
Test Verb aliases when one verb is set as a default.
void Parse_help_option_for_aliased_verbs_no_default(string args, bool verbsIndex, string[] expected)
Verify auto-help generation with no default verb.
void Parse_option_with_aliased_verb(string args, Type expectedArgType)
Test verb aliases with no default verb and 1 verb with no aliases.
void Parse_help_option_for_aliased_verbs(string args, bool verbsIndex, string[] expected)
Verify auto-help generation.
override string ToString()
Returns the help screen as a System.String.