1 <?xml version="1.0" encoding="UTF-8"?>
2 <Type Name="CommandSet" FullName="Mono.Options.CommandSet">
3 <TypeSignature Language="C#" Value="public class CommandSet : System.Collections.ObjectModel.KeyedCollection<string,Mono.Options.Command>" />
4 <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit CommandSet extends System.Collections.ObjectModel.KeyedCollection`2<string, class Mono.Options.Command>" />
6 <AssemblyName>Mono.Options</AssemblyName>
7 <AssemblyVersion>0.2.3.0</AssemblyVersion>
9 <ThreadingSafetyStatement>
10 Public <c>static</c> members of this type are thread safe.
11 Any instance members are not guaranteed to be thread safe.
12 </ThreadingSafetyStatement>
14 <BaseTypeName>System.Collections.ObjectModel.KeyedCollection<System.String,Mono.Options.Command></BaseTypeName>
16 <BaseTypeArgument TypeParamName="!0">System.String</BaseTypeArgument>
17 <BaseTypeArgument TypeParamName="!1">Mono.Options.Command</BaseTypeArgument>
23 A <i>suite</i> of commands, global program options, and associated documentation.
27 A common requirement of some programs are discrete <i>commands</i>.
28 A <c>CommandSet</c> represents a <i>suite</i> of commands, intermixed
29 with suite documentation. Commands are managed by
30 <see cref="T:Mono.Options.Command" /> instances, which have a required
31 <i>name</i> and optional help text, and <c>CommandSet</c> will use the
32 intermixed documentation, options, and commands to produce <c>help</c>
36 To create a <c>CommandSet</c> instance, use the
37 <see cref="C:Mono.Options.CommandSet(System.String, System.Converter, System.IO.TextWriter, System.IO.TextWriter)" />
38 constructor. Only the suite name is required; all other parameters are
42 Once a <c>CommandSet</c> instance has been constructed, use the
43 <see cref="M:Mono.Options.CommandSet.Add" /> methods to add and
44 intermix suite documentation, global options, and commands.
45 Documentation is any string constant, global options are handled
46 by <see cref="T:Mono.Options.Option" /> instances and associated
47 <c>Add()</c> method overloads which implicitly create <c>Option</c>
48 instances, and commands are through <c>Command</c> instances.
51 Once the <c>CommandSet</c> instance has been initialized, call the
52 <see cref="M:Mono.Options.CommandSet.Run(System.String[])" />
53 method to process the arguments provided to <c>Main()</c>.
54 The appropriate <c>Command</c> instance will be determined, it's
55 options parsed, and <see cref="M:Mono.Options.Command.Invoke" />
56 will be executed. The return value of <c>Command.Invoke()</c>
57 is returned from <c>CommandSet.Run()</c>, and should be treated
58 as the process exit value.
63 The following <c>commands</c> example demonstrates some simple usage
64 of <see cref="T:Mono.Options.CommandSet" />.
66 <code lang="C#" src="examples/commands.cs">// Sub-commands with Mono.Options.CommandSet
69 // mcs -r:Mono.Options.dll commands.cs
72 using System.Collections.Generic;
77 public static int Main (string[] args)
79 var commands = new CommandSet ("commands") {
80 "usage: commands COMMAND [OPTIONS]",
82 "Mono.Options.CommandSet sample app.",
87 (int? n) => Verbosity = n.HasValue ? n.Value : Verbosity + 1 },
89 "Available commands:",
90 new Command ("echo", "Echo arguments to the screen") {
91 Run = ca => Console.WriteLine ("{0}", string.Join (" ", ca)),
95 return commands.Run (args);
98 public static int Verbosity;
101 class RequiresArgs : Command {
103 public RequiresArgs ()
104 : base ("requires-args", "Class-based Command subclass")
106 Options = new OptionSet () {
107 "usage: commands requires-args [OPTIONS]",
109 "Class-based Command subclass example.",
111 "{name} of person to greet.",
114 "Show this message and exit.",
115 v => ShowHelp = v != null },
119 public bool ShowHelp {get; private set;}
120 public new string Name {get; private set;}
122 public override int Invoke (IEnumerable<string> args)
125 var extra = Options.Parse (args);
127 Options.WriteOptionDescriptions (CommandSet.Out);
130 if (string.IsNullOrEmpty (Name)) {
131 Console.Error.WriteLine ("commands: Missing required argument `--name=NAME`.");
132 Console.Error.WriteLine ("commands: Use `commands help requires-args` for details.");
135 Console.WriteLine ($"Hello, {Name}!");
138 catch (Exception e) {
139 Console.Error.WriteLine ("commands: {0}", CommandDemo.Verbosity >= 1 ? e.ToString () : e.Message);
146 The output, under the influence of different command-line arguments, is:
148 <code lang="sh" src="examples/commands.txt">$ mono commands.exe
149 Use `commands help` for usage.
151 $ mono commands.exe --help
152 usage: commands COMMAND [OPTIONS]
154 Mono.Options.CommandSet sample app.
157 -v[=VALUE] Output verbosity.
160 echo Echo arguments to the screen
161 requires-args Class-based Command subclass
163 $ mono commands.exe help
164 usage: commands COMMAND [OPTIONS]
166 Mono.Options.CommandSet sample app.
169 -v[=VALUE] Output verbosity.
172 echo Echo arguments to the screen
173 requires-args Class-based Command subclass
175 $ mono commands.exe help --help
176 Usage: commands COMMAND [OPTIONS]
177 Use `commands help COMMAND` for help on a specific command.
181 echo Echo arguments to the screen
182 requires-args Class-based Command subclass
183 help Show this message and exit
185 $ mono commands.exe help echo
188 $ mono commands.exe echo --help
191 $ mono commands.exe echo hello, world
194 $ mono commands.exe requires-args
195 commands: Missing required argument `--name=NAME`.
196 commands: Use `commands help requires-args` for details.
198 $ mono commands.exe help requires-args
199 usage: commands requires-args [OPTIONS]
201 Class-based Command subclass example.
202 --name, -n=name name of person to greet.
203 --help, -h, -? Show this message and exit.
205 $ mono commands.exe requires-args --help
206 usage: commands requires-args [OPTIONS]
208 Class-based Command subclass example.
209 --name, -n=name name of person to greet.
210 --help, -h, -? Show this message and exit.
212 $ mono commands.exe requires-args -n World
215 $ mono commands.exe invalid-command
216 commands: Unknown command: invalid-command
217 commands: Use `commands help` for usage.
219 $ mono commands.exe help invalid-command
220 commands: Unknown command: invalid-command
221 commands: Use `commands help` for usage.
224 The <c>commands.exe</c> output is short, informing the user that
225 commands are required for use.
228 The <c>commands.exe --help</c> is identical to the <c>commands help</c>
229 output, and shows the provided suite documentation.
232 <c>commands.exe COMMAND --help</c> and <c>commands.exe help COMMAND</c>
233 output is likewise identical, and will attempt to generate documentation
234 for the specified command, if available. This is performed by invoking
235 <see cref="M:Mono.Options.Command.Invoke(System.Collections.Generic.IEnumerable{System.String})" />
236 with the value <c>{ "--help" }</c>. This can be seen in the
237 <c>commands.exe help echo</c> and <c>commands.exe echo --help</c>
238 output, which simply prints <c>--help</c>. If a command wants
239 to partake in <c>help COMMAND</c> support, it needs to explicitly
240 handle the <c>--help</c> option in its associated
241 <see cref="T:Mono.Options.OptionSet" /> instance, referenced by the
242 <see cref="P:Mono.Options.Command.Options" /> property.
245 Finally, if an invalid command is specified, then an error is written
246 to <see cref="P:Mono.Options.CommandSet.Error" />, prefixed with the
247 <see cref="P:Mono.Options.CommandSet.Suite" /> value.
252 <Member MemberName=".ctor">
253 <MemberSignature Language="C#" Value="public CommandSet (string suite, Converter<string,string> localizer = null);" />
254 <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string suite, class System.Converter`2<string, string> localizer) cil managed" />
255 <MemberType>Constructor</MemberType>
257 <AssemblyVersion>0.2.3.0</AssemblyVersion>
260 <Parameter Name="suite" Type="System.String" />
261 <Parameter Name="localizer" Type="System.Converter<System.String,System.String>" />
265 A <see cref="T:System.String" /> containing the name of the suite.
266 This value is used in default <c>help</c> text output.
268 <param name="localizer">
269 A <see cref="T:System.Converter{System.String,System.String}" />
270 instance that will be used to translate strings.
271 If <see langword="null" />, then no localization is performed.
274 Creates and initializes a new <c>CommandSet</c> instance.
278 This constructor initializes
279 the <see cref="P:Mono.Options.CommandSet.Suite" /> property
280 of the new instance using <paramref name="suite" />,
281 the <see cref="P:Mono.Options.CommandSet.MessageLocalizer" /> property
282 of the new instance using <paramref name="localizer" />,
283 the <see cref="P:Mono.Options.CommandSet.Out" /> property
284 to <see cref="P:System.Console.Out" />, and
285 the <see cref="P:Mono.Options.CommandSet.Error" /> property
286 to <see cref="P:System.Console.Error" />.
289 <exception cref="T:System.ArgumentNullException">
290 <paramref name="suite" /> is <see langword="null" />.
294 <Member MemberName=".ctor">
295 <MemberSignature Language="C#" Value="public CommandSet (string suite, System.IO.TextWriter output, System.IO.TextWriter error, Converter<string,string> localizer = null);" />
296 <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string suite, class System.IO.TextWriter output, class System.IO.TextWriter error, class System.Converter`2<string, string> localizer) cil managed" />
297 <MemberType>Constructor</MemberType>
299 <AssemblyVersion>0.2.3.0</AssemblyVersion>
302 <Parameter Name="suite" Type="System.String" />
303 <Parameter Name="output" Type="System.IO.TextWriter" />
304 <Parameter Name="error" Type="System.IO.TextWriter" />
305 <Parameter Name="localizer" Type="System.Converter<System.String,System.String>" />
309 A <see cref="T:System.String" /> containing the name of the suite.
310 This value is used in default <c>help</c> text output.
312 <param name="output">
313 A <see cref="T:System.IO.TextWriter" /> where output messages will be
317 A <see cref="T:System.IO.TextWriter" /> where error messages will be
320 <param name="localizer">
321 A <see cref="T:System.Converter{System.String,System.String}" />
322 instance that will be used to translate strings.
323 If <see langword="null" />, then no localization is performed.
326 Creates and initializes a new <c>CommandSet</c> instance.
330 This constructor initializes
331 the <see cref="P:Mono.Options.CommandSet.Suite" /> property
332 of the new instance using <paramref name="suite" />,
333 the <see cref="P:Mono.Options.CommandSet.MessageLocalizer" /> property
334 of the new instance using <paramref name="localizer" />,
335 the <see cref="P:Mono.Options.CommandSet.Out" /> property
336 of the new instance using <paramref name="output" />, and
337 the <see cref="P:Mono.Options.CommandSet.Error" /> property
338 of the new instance using <paramref name="error" />.
341 <exception cref="T:System.ArgumentNullException">
342 <paramref name="suite" /> is <see langword="null" />.
344 <exception cref="T:System.ArgumentNullException">
345 <paramref name="output" /> is <see langword="null" />.
347 <exception cref="T:System.ArgumentNullException">
348 <paramref name="error" /> is <see langword="null" />.
352 <Member MemberName="Add">
353 <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add (Mono.Options.ArgumentSource source);" />
354 <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add(class Mono.Options.ArgumentSource source) cil managed" />
355 <MemberType>Method</MemberType>
357 <AssemblyVersion>0.2.3.0</AssemblyVersion>
360 <ReturnType>Mono.Options.CommandSet</ReturnType>
363 <Parameter Name="source" Type="Mono.Options.ArgumentSource" />
366 <param name="source">
367 A <see cref="T:Mono.Options.ArgumentSource" /> to register for
371 Registers <paramref name="source" /> so that it may be consulted
372 during argument processing within
373 <see cref="M:Mono.Options.CommandSet.Run(System.Collections.Generic.IEnumerable{System.String})" />.
376 The current <see cref="T:Mono.Options.CommandSet" /> instance.
377 This is to permit method chaining.
381 <exception cref="T:System.ArgumentNullException">
382 <paramref name="source" /> is <see langword="null" />.
386 <Member MemberName="Add">
387 <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add (Mono.Options.Command value);" />
388 <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add(class Mono.Options.Command value) cil managed" />
389 <MemberType>Method</MemberType>
391 <AssemblyVersion>0.2.3.0</AssemblyVersion>
394 <ReturnType>Mono.Options.CommandSet</ReturnType>
397 <Parameter Name="value" Type="Mono.Options.Command" />
401 A <see cref="T:Mono.Options.Command" /> to add to the suite.
404 Add a <c>Command</c> to the suite.
407 The current <see cref="T:Mono.Options.CommandSet" /> instance.
408 This is to permit method chaining.
412 <exception cref="T:System.ArgumentException">
414 A <c>Command</c> with the same value for
415 <c><paramref name="value" />.Name</c>
416 has already been added to the <c>CommandSet</c>.
420 <paramref name="value" /> has been <c>Add()</c>ed to a different
421 <c>CommandSet</c> instance.
424 <exception cref="T:System.ArgumentNullException">
425 <paramref name="value" /> is <see langword="null" />.
429 <Member MemberName="Add">
430 <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add (Mono.Options.Option option);" />
431 <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add(class Mono.Options.Option option) cil managed" />
432 <MemberType>Method</MemberType>
434 <AssemblyVersion>0.2.3.0</AssemblyVersion>
437 <ReturnType>Mono.Options.CommandSet</ReturnType>
440 <Parameter Name="option" Type="Mono.Options.Option" />
443 <param name="option">
444 The <see cref="T:Mono.Options.Option" /> to register.
447 Adds <paramref name="option" /> as a global suite option.
450 The current <see cref="T:Mono.Options.CommandSet" /> instance.
451 This is to permit method chaining.
455 Registers each option name returned by
456 <see cref="M:Mono.Options.Option.GetNames" />, ensuring that any
457 option with a matching name will be handled by the
458 <paramref name="option" /> instance.
461 <exception cref="T:System.ArgumentException">
462 <paramref name="option" /> has an alias (as returned from
463 <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
464 a previously registered <see cref="T:Mono.Options.Option" />.
466 <exception cref="T:System.ArgumentNullException">
467 <paramref name="option" /> is <see langword="null" />.
471 <Member MemberName="Add">
472 <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add (string header);" />
473 <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add(string header) cil managed" />
474 <MemberType>Method</MemberType>
476 <AssemblyVersion>0.2.3.0</AssemblyVersion>
479 <ReturnType>Mono.Options.CommandSet</ReturnType>
482 <Parameter Name="header" Type="System.String" />
485 <param name="header">
486 A <see cref="T:System.String" /> containing the header to display
487 during <see cref="M:Mono.Options.CommandSet.Run" /><c>help</c> processing.
490 Declare a header to be printed during for <c>help</c> output.
493 The current <see cref="T:Mono.Options.CommandSet" /> instance.
494 This is to permit method chaining.
500 <Member MemberName="Add">
501 <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add (string prototype, Mono.Options.OptionAction<string,string> action);" />
502 <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add(string prototype, class Mono.Options.OptionAction`2<string, string> action) cil managed" />
503 <MemberType>Method</MemberType>
505 <AssemblyVersion>0.2.3.0</AssemblyVersion>
508 <ReturnType>Mono.Options.CommandSet</ReturnType>
511 <Parameter Name="prototype" Type="System.String" />
512 <Parameter Name="action" Type="Mono.Options.OptionAction<System.String,System.String>" />
515 <param name="prototype">
516 A <see cref="T:System.String" /> containing all option aliases to
517 register, an (optional) type specifier, and an (optional) value
519 <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
522 <param name="action">
523 A <see cref="T:Mono.Options.OptionAction{System.String,System.String}" />
524 to invoke when an option is parsed.
527 Registers each alias within <paramref name="prototype" /> so that any
528 options matching the aliases in <paramref name="prototype" /> will be
529 handled by <paramref name="action" /> during any subsequent
530 <see cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />
534 The current <see cref="T:Mono.Options.CommandSet" /> instance.
535 This is to permit method chaining.
539 <see cref="M:Mono.Options.CommandSet.Add(System.String,System.String,Mono.Options.OptionAction{System.String,System.String})" />
540 with a <paramref name="description" /> value of
541 <see langword="null" />.
543 <altmember cref="M:Mono.Options.CommandSet.Add(System.String,System.String,Mono.Options.OptionAction{System.String,System.String})" />
544 <altmember cref="M:Mono.Options.CommandSet.Add(Mono.Options.Option)" />
545 <exception cref="T:System.ArgumentException">
546 <paramref name="prototype" /> has an alias (as returned from
547 <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
548 a previously registered <see cref="T:Mono.Options.Option" />.
550 <exception cref="T:System.ArgumentNullException">
552 <paramref name="prototype" /> is <see langword="null" /></para>
555 <paramref name="action" /> is <see langword="null" /></para>
559 <Member MemberName="Add">
560 <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add (string prototype, Action<string> action);" />
561 <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add(string prototype, class System.Action`1<string> action) cil managed" />
562 <MemberType>Method</MemberType>
564 <AssemblyVersion>0.2.3.0</AssemblyVersion>
567 <ReturnType>Mono.Options.CommandSet</ReturnType>
570 <Parameter Name="prototype" Type="System.String" />
571 <Parameter Name="action" Type="System.Action<System.String>" />
574 <param name="prototype">
575 A <see cref="T:System.String" /> containing all option aliases to
576 register, an (optional) type specifier, and an (optional) value
578 <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
581 <param name="action">
582 A <see cref="T:System.Action{System.String}" />
583 to invoke when an option is parsed.
586 Registers each alias within <paramref name="prototype" /> so that any
587 options matching the aliases in <paramref name="prototype" /> will be
588 handled by <paramref name="action" /> during any subsequent
589 <see cref="M:Mono.Options.CommandSet.Run(System.Collections.Generic.IEnumerable{System.String})" />
593 The current <see cref="T:Mono.Options.CommandSet" /> instance.
594 This is to permit method chaining.
598 <see cref="M:Mono.Options.CommandSet.Add(System.String,System.String,System.Action{System.String})" />
599 with a <paramref name="description" /> value of
600 <see langword="null" />.
602 <altmember cref="M:Mono.Options.CommandSet.Add(System.String,System.String,System.Action{System.String})" />
603 <altmember cref="M:Mono.Options.CommandSet.Add(Mono.Options.Option)" />
604 <exception cref="T:System.ArgumentException">
605 <paramref name="prototype" /> has an alias (as returned from
606 <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
607 a previously registered <see cref="T:Mono.Options.Option" />.
609 <exception cref="T:System.ArgumentNullException">
611 <paramref name="prototype" /> is <see langword="null" /></para>
614 <paramref name="action" /> is <see langword="null" /></para>
618 <Member MemberName="Add">
619 <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add (string prototype, string description, Mono.Options.OptionAction<string,string> action);" />
620 <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add(string prototype, string description, class Mono.Options.OptionAction`2<string, string> action) cil managed" />
621 <MemberType>Method</MemberType>
623 <AssemblyVersion>0.2.3.0</AssemblyVersion>
626 <ReturnType>Mono.Options.CommandSet</ReturnType>
629 <Parameter Name="prototype" Type="System.String" />
630 <Parameter Name="description" Type="System.String" />
631 <Parameter Name="action" Type="Mono.Options.OptionAction<System.String,System.String>" />
634 <param name="prototype">
635 A <see cref="T:System.String" /> containing all option aliases to
636 register, an (optional) type specifier, and an (optional) value
638 <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
641 <param name="description">
642 A <see cref="T:System.String" /> to be used to initialize
643 the <see cref="P:Mono.Options.Option.Description" /> property.
645 <param name="action">
646 A <see cref="T:Mono.Options.OptionAction{System.String,System.String}" />
647 to invoke when an option is parsed.
650 Registers each alias within <paramref name="prototype" /> so that any
651 options matching the aliases in <paramref name="prototype" /> will be
652 handled by <paramref name="action" /> during any subsequent
653 <see cref="M:Mono.Options.CommandSet.Run(System.Collections.Generic.IEnumerable{System.String})" />
657 The current <see cref="T:Mono.Options.CommandSet" /> instance.
658 This is to permit method chaining.
662 Use this method when <paramref name="prototype" /> should accept
663 two values, generally a key and a value.
665 <block subset="none" type="note">
666 If <paramref name="prototype" /> specifies a
667 <see cref="F:Mono.Options.OptionValueType.Optional" /> option,
668 then it's possible that both the key and the value will be
669 <see langword="null" /> in the callback function.
672 <altmember cref="M:Mono.Options.CommandSet.Add(Mono.Options.Option)" />
673 <exception cref="T:System.ArgumentException">
674 <paramref name="prototype" /> has an alias (as returned from
675 <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
676 a previously registered <see cref="T:Mono.Options.Option" />.
678 <exception cref="T:System.ArgumentNullException">
680 <paramref name="prototype" /> is <see langword="null" /></para>
683 <paramref name="action" /> is <see langword="null" /></para>
687 <Member MemberName="Add">
688 <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add (string prototype, string description, Action<string> action);" />
689 <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add(string prototype, string description, class System.Action`1<string> action) cil managed" />
690 <MemberType>Method</MemberType>
692 <AssemblyVersion>0.2.3.0</AssemblyVersion>
695 <ReturnType>Mono.Options.CommandSet</ReturnType>
698 <Parameter Name="prototype" Type="System.String" />
699 <Parameter Name="description" Type="System.String" />
700 <Parameter Name="action" Type="System.Action<System.String>" />
703 <param name="prototype">
704 A <see cref="T:System.String" /> containing all option aliases to
705 register, an (optional) type specifier, and an (optional) value
707 <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
710 <param name="description">
711 A <see cref="T:System.String" /> containing to used to initialize
712 the <see cref="P:Mono.Options.Option.Description" /> property.
714 <param name="action">
715 A <see cref="T:System.Action{System.String}" />
716 to invoke when an option is parsed.
719 Registers each alias within <paramref name="prototype" /> so that any
720 options matching the aliases in <paramref name="prototype" /> will be
721 handled by <paramref name="action" /> during any subsequent
722 <see cref="M:Mono.Options.CommandSet.Run(System.Collections.Generic.IEnumerable{System.String})" />
726 The current <see cref="T:Mono.Options.CommandSet" /> instance.
727 This is to permit method chaining.
731 <altmember cref="M:Mono.Options.CommandSet.Add(Mono.Options.Option)" />
732 <exception cref="T:System.ArgumentException">
733 <paramref name="option" /> has an alias (as returned from
734 <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
735 a previously registered <see cref="T:Mono.Options.Option" />.
737 <exception cref="T:System.ArgumentNullException">
739 <paramref name="prototype" /> is <see langword="null" /></para>
742 <paramref name="action" /> is <see langword="null" /></para>
746 <Member MemberName="Add">
747 <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add (string prototype, string description, Mono.Options.OptionAction<string,string> action, bool hidden);" />
748 <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add(string prototype, string description, class Mono.Options.OptionAction`2<string, string> action, bool hidden) cil managed" />
749 <MemberType>Method</MemberType>
751 <AssemblyVersion>0.2.3.0</AssemblyVersion>
754 <ReturnType>Mono.Options.CommandSet</ReturnType>
757 <Parameter Name="prototype" Type="System.String" />
758 <Parameter Name="description" Type="System.String" />
759 <Parameter Name="action" Type="Mono.Options.OptionAction<System.String,System.String>" />
760 <Parameter Name="hidden" Type="System.Boolean" />
763 <param name="prototype">
764 A <see cref="T:System.String" /> containing all option aliases to
765 register, an (optional) type specifier, and an (optional) value
767 <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
770 <param name="description">
771 A <see cref="T:System.String" /> containing to used to initialize
772 the <see cref="P:Mono.Options.Option.Description" /> property.
774 <param name="action">
775 A <see cref="T:Mono.Options.OptionAction{System.String,System.String}" />
776 to invoke when an option is parsed.
778 <param name="hidden">
779 A <see cref="T:System.Boolean" /> specifying whether or not the
780 Option should be displayed in
781 <see cref="M:Mono.Options.CommandSet.Run" /><c>help</c> output.
784 Registers each alias within <paramref name="prototype" /> so that any
785 options matching the aliases in <paramref name="prototype" /> will be
786 handled by <paramref name="action" /> during any subsequent
787 <see cref="M:Mono.Options.CommandSet.Run(System.Collections.Generic.IEnumerable{System.String})" />
791 The current <see cref="T:Mono.Options.CommandSet" /> instance.
792 This is to permit method chaining.
796 <altmember cref="M:Mono.Options.CommandSet.Add(Mono.Options.Option)" />
797 <exception cref="T:System.ArgumentException">
798 <paramref name="option" /> has an alias (as returned from
799 <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
800 a previously registered <see cref="T:Mono.Options.Option" />.
802 <exception cref="T:System.ArgumentNullException">
804 <paramref name="prototype" /> is <see langword="null" /></para>
807 <paramref name="action" /> is <see langword="null" /></para>
811 <Member MemberName="Add">
812 <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add (string prototype, string description, Action<string> action, bool hidden);" />
813 <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add(string prototype, string description, class System.Action`1<string> action, bool hidden) cil managed" />
814 <MemberType>Method</MemberType>
816 <AssemblyVersion>0.2.3.0</AssemblyVersion>
819 <ReturnType>Mono.Options.CommandSet</ReturnType>
822 <Parameter Name="prototype" Type="System.String" />
823 <Parameter Name="description" Type="System.String" />
824 <Parameter Name="action" Type="System.Action<System.String>" />
825 <Parameter Name="hidden" Type="System.Boolean" />
828 <param name="prototype">
829 A <see cref="T:System.String" /> containing all option aliases to
830 register, an (optional) type specifier, and an (optional) value
832 <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
835 <param name="description">
836 A <see cref="T:System.String" /> containing to used to initialize
837 the <see cref="P:Mono.Options.Option.Description" /> property.
839 <param name="action">
840 A <see cref="T:System.Action{System.String}" />
841 to invoke when an option is parsed.
843 <param name="hidden">
844 A <see cref="T:System.Boolean" /> specifying whether or not the
845 Option should be displayed in
846 <see cref="M:Mono.Options.CommandSet.Run" /><c>help</c> output.
849 Registers each alias within <paramref name="prototype" /> so that any
850 options matching the aliases in <paramref name="prototype" /> will be
851 handled by <paramref name="action" /> during any subsequent
852 <see cref="M:Mono.Options.CommandSet.Run(System.Collections.Generic.IEnumerable{System.String})" />
856 The current <see cref="T:Mono.Options.CommandSet" /> instance.
857 This is to permit method chaining.
861 <altmember cref="M:Mono.Options.OptionSet.Add(Mono.Options.Option)" />
862 <exception cref="T:System.ArgumentException">
863 <paramref name="option" /> has an alias (as returned from
864 <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
865 a previously registered <see cref="T:Mono.Options.Option" />.
867 <exception cref="T:System.ArgumentNullException">
869 <paramref name="prototype" /> is <see langword="null" /></para>
872 <paramref name="action" /> is <see langword="null" /></para>
876 <Member MemberName="Add<T>">
877 <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add<T> (string prototype, Action<T> action);" />
878 <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add<T>(string prototype, class System.Action`1<!!T> action) cil managed" />
879 <MemberType>Method</MemberType>
881 <AssemblyVersion>0.2.3.0</AssemblyVersion>
884 <ReturnType>Mono.Options.CommandSet</ReturnType>
887 <TypeParameter Name="T" />
890 <Parameter Name="prototype" Type="System.String" />
891 <Parameter Name="action" Type="System.Action<T>" />
895 The type of the option to parse and provide to the
896 <paramref name="action" /> callback.
898 <param name="prototype">
899 A <see cref="T:System.String" /> containing all option aliases to
900 register, an (optional) type specifier, and an (optional) value
902 <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
905 <param name="action">
906 A <see cref="T:System.Action{``0}" />
907 to invoke when an option is parsed.
910 Registers each alias within <paramref name="prototype" /> so that any
911 options matching the aliases in <paramref name="prototype" /> will be
912 handled by <paramref name="action" /> during any subsequent
913 <see cref="M:Mono.Options.CommandSet.Run(System.Collections.Generic.IEnumerable{System.String})" />
917 The current <see cref="T:Mono.Options.CommandSet" /> instance.
918 This is to permit method chaining.
922 <see cref="M:Mono.Options.OptionSet.Add``1(System.String,System.String,System.Action{``0})" />
923 with a <paramref name="description" /> value of
924 <see langword="null" />.
926 <altmember cref="M:Mono.Options.CommandSet.Add(Mono.Options.Option)" />
927 <altmember cref="M:Mono.Options.CommandSet.Add``1(System.String,System.String,System.Action{``0})" />
928 <exception cref="T:System.ArgumentException">
929 <paramref name="option" /> has an alias (as returned from
930 <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
931 a previously registered <see cref="T:Mono.Options.Option" />.
935 <Member MemberName="Add<T>">
936 <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add<T> (string prototype, string description, Action<T> action);" />
937 <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add<T>(string prototype, string description, class System.Action`1<!!T> action) cil managed" />
938 <MemberType>Method</MemberType>
940 <AssemblyVersion>0.2.3.0</AssemblyVersion>
943 <ReturnType>Mono.Options.CommandSet</ReturnType>
946 <TypeParameter Name="T" />
949 <Parameter Name="prototype" Type="System.String" />
950 <Parameter Name="description" Type="System.String" />
951 <Parameter Name="action" Type="System.Action<T>" />
955 The type of the option to parse and provide to the
956 <paramref name="action" /> callback.
958 <param name="prototype">
959 A <see cref="T:System.String" /> containing all option aliases to
960 register, an (optional) type specifier, and an (optional) value
962 <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
965 <param name="description">
966 A <see cref="T:System.String" /> containing to used to initialize
967 the <see cref="P:Mono.Options.Option.Description" /> property.
969 <param name="action">
970 A <see cref="T:System.Action{``0}" />
971 to invoke when an option is parsed.
974 Registers each alias within <paramref name="prototype" /> so that any
975 options matching the aliases in <paramref name="prototype" /> will be
976 handled by <paramref name="action" /> during any subsequent
977 <see cref="M:Mono.Options.CommandSet.Run(System.Collections.Generic.IEnumerable{System.String})" />
981 The current <see cref="T:Mono.Options.CommandSet" /> instance.
982 This is to permit method chaining.
986 Use this typed overload when you want strongly typed option values
987 that correspond to a managed type.
988 <see cref="M:System.ComponentModel.TypeDescriptor.GetConverter(System.Type)" />
989 is used to lookup the
990 <see cref="T:System.ComponentModel.TypeConverter" /> to use when
991 performing the string-to-type conversion.
994 Special support is provided for <see cref="T:System.Nullable{X}" />
995 types; <see cref="T:System.ComponentModel.TypeConverter" />
996 doesn't currently support their use, but if
997 <typeparamref name="T" /> is a nullable type, then this method
999 <see cref="T:System.ComponentModel.TypeConverter" /> for the
1000 <typeparamref name="X" /> type. This allows straightforward use
1001 of nullable types, identical to using any other strongly typed
1004 <block subset="none" type="note">
1006 If <paramref name="prototype" /> specifies an
1007 <see cref="F:Mono.Options.OptionValueType.Optional" /> value
1008 and the value is not provided, then <c>default(T)</c> is
1009 provided as the value to <paramref name="action" />.
1013 <altmember cref="M:Mono.Options.OptionSet.Add(Mono.Options.Option)" />
1014 <exception cref="T:System.ArgumentException">
1015 <paramref name="option" /> has an alias (as returned from
1016 <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
1017 a previously registered <see cref="T:Mono.Options.Option" />.
1019 <exception cref="T:System.ArgumentNullException">
1021 <paramref name="prototype" /> is <see langword="null" /></para>
1024 <paramref name="action" /> is <see langword="null" /></para>
1028 <Member MemberName="Add<TKey,TValue>">
1029 <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add<TKey,TValue> (string prototype, Mono.Options.OptionAction<TKey,TValue> action);" />
1030 <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add<TKey, TValue>(string prototype, class Mono.Options.OptionAction`2<!!TKey, !!TValue> action) cil managed" />
1031 <MemberType>Method</MemberType>
1033 <AssemblyVersion>0.2.3.0</AssemblyVersion>
1036 <ReturnType>Mono.Options.CommandSet</ReturnType>
1039 <TypeParameter Name="TKey" />
1040 <TypeParameter Name="TValue" />
1043 <Parameter Name="prototype" Type="System.String" />
1044 <Parameter Name="action" Type="Mono.Options.OptionAction<TKey,TValue>" />
1047 <typeparam name="TKey">
1048 The type of the first argument to parse and provide to the
1049 <paramref name="action" /> callback.
1051 <typeparam name="TValue">
1052 The type of the second argument to parse and provide to the
1053 <paramref name="action" /> callback.
1055 <param name="prototype">
1056 A <see cref="T:System.String" /> containing all option aliases to
1057 register, an (optional) type specifier, and an (optional) value
1059 <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
1062 <param name="action">
1063 A <see cref="T:Mono.Options.OptionAction{TKey,TValue}" />
1064 to invoke when an option is parsed.
1067 Registers each alias within <paramref name="prototype" /> so that any
1068 options matching the aliases in <paramref name="prototype" /> will be
1069 handled by <paramref name="action" /> during any subsequent
1070 <see cref="M:Mono.Options.CommandSet.Run(System.Collections.Generic.IEnumerable{System.String})" />
1074 The current <see cref="T:Mono.Options.CommandSet" /> instance.
1075 This is to permit method chaining.
1079 <see cref="M:Mono.Options.OptionSet.Add``2(System.String,System.String,Mono.Options.OptionAction{``0,``1})" />
1080 with a <paramref name="description" /> value of
1081 <see langword="null" />.
1083 <altmember cref="M:Mono.Options.CommandSet.Add(Mono.Options.Option)" />
1084 <altmember cref="M:Mono.Options.CommandSet.Add``2(System.String,System.String,Mono.Options.OptionAction{``0,``1})" />
1085 <exception cref="T:System.ArgumentException">
1086 <paramref name="prototype" /> has an alias (as returned from
1087 <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
1088 a previously registered <see cref="T:Mono.Options.Option" />.
1090 <exception cref="T:System.ArgumentNullException">
1092 <paramref name="prototype" /> is <see langword="null" /></para>
1095 <paramref name="action" /> is <see langword="null" /></para>
1099 <Member MemberName="Add<TKey,TValue>">
1100 <MemberSignature Language="C#" Value="public Mono.Options.CommandSet Add<TKey,TValue> (string prototype, string description, Mono.Options.OptionAction<TKey,TValue> action);" />
1101 <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.CommandSet Add<TKey, TValue>(string prototype, string description, class Mono.Options.OptionAction`2<!!TKey, !!TValue> action) cil managed" />
1102 <MemberType>Method</MemberType>
1104 <AssemblyVersion>0.2.3.0</AssemblyVersion>
1107 <ReturnType>Mono.Options.CommandSet</ReturnType>
1110 <TypeParameter Name="TKey" />
1111 <TypeParameter Name="TValue" />
1114 <Parameter Name="prototype" Type="System.String" />
1115 <Parameter Name="description" Type="System.String" />
1116 <Parameter Name="action" Type="Mono.Options.OptionAction<TKey,TValue>" />
1119 <typeparam name="TKey">
1120 The type of the first argument to parse and provide to the
1121 <paramref name="action" /> callback.
1123 <typeparam name="TValue">
1124 The type of the second argument to parse and provide to the
1125 <paramref name="action" /> callback.
1127 <param name="prototype">
1128 A <see cref="T:System.String" /> containing all option aliases to
1129 register, an (optional) type specifier, and an (optional) value
1131 <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
1134 <param name="description">
1135 A <see cref="T:System.String" /> to be used to initialize
1136 the <see cref="P:Mono.Options.Option.Description" /> property.
1138 <param name="action">
1139 A <see cref="T:Mono.Options.OptionAction{TKey,TValue}" />
1140 to invoke when an option is parsed.
1143 Registers each alias within <paramref name="prototype" /> so that any
1144 options matching the aliases in <paramref name="prototype" /> will be
1145 handled by <paramref name="action" /> during any subsequent
1146 <see cref="M:Mono.Options.CommandSet.Run(System.Collections.Generic.IEnumerable{System.String})" />
1150 The current <see cref="T:Mono.Options.CommandSet" /> instance.
1151 This is to permit method chaining.
1155 Use this method when <paramref name="prototype" /> should accept
1156 two typed values, generally a key and a value.
1158 <block subset="none" type="note">
1160 If <paramref name="prototype" /> specifies an
1161 <see cref="F:Mono.Options.OptionValueType.Optional" /> value
1162 and the value is not provided, then <c>default(TKey)</c> and
1163 <c>default(TValue)</c> may be provided as the values to
1164 <paramref name="action" />.
1168 <altmember cref="M:Mono.Options.CommandSet.Add(Mono.Options.Option)" />
1169 <exception cref="T:System.ArgumentException">
1170 <paramref name="prototype" /> has an alias (as returned from
1171 <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
1172 a previously registered <see cref="T:Mono.Options.Option" />.
1174 <exception cref="T:System.ArgumentNullException">
1176 <paramref name="prototype" /> is <see langword="null" /></para>
1179 <paramref name="action" /> is <see langword="null" /></para>
1183 <Member MemberName="Error">
1184 <MemberSignature Language="C#" Value="public System.IO.TextWriter Error { get; }" />
1185 <MemberSignature Language="ILAsm" Value=".property instance class System.IO.TextWriter Error" />
1186 <MemberType>Property</MemberType>
1188 <AssemblyVersion>0.2.3.0</AssemblyVersion>
1191 <ReturnType>System.IO.TextWriter</ReturnType>
1195 Where <c>CommandSet</c> should write error messages.
1198 A <see cref="T:System.IO.TextWriter" /> where error messages will
1203 This value may be set by providing the <paramref name="error" />
1204 constructor parameter. If not specified, then
1205 <see cref="P:System.Console.Error" /> will be used.
1208 Error messages by <c>CommandSet</c> are written to the <c>Error</c>
1209 property. <c>Command</c> instances may also choose to write error
1210 messages to the <c>CommandSet.Error</c> property. This is suggested
1211 to help with unit testing.
1216 <Member MemberName="GetKeyForItem">
1217 <MemberSignature Language="C#" Value="protected override string GetKeyForItem (Mono.Options.Command item);" />
1218 <MemberSignature Language="ILAsm" Value=".method familyhidebysig virtual instance string GetKeyForItem(class Mono.Options.Command item) cil managed" />
1219 <MemberType>Method</MemberType>
1221 <AssemblyVersion>0.2.3.0</AssemblyVersion>
1224 <ReturnType>System.String</ReturnType>
1227 <Parameter Name="item" Type="Mono.Options.Command" />
1231 An <see cref="T:Mono.Options.Command" /> to return the key of.
1234 Returns <c><paramref name="item" />.Name</c>.
1237 A <see cref="T:System.String" /> containing the command name.
1241 This is to support the
1242 <see cref="T:System.Collections.ObjectModel.KeyedCollection{System.String,Mono.Options.Command}" />
1248 <Member MemberName="MessageLocalizer">
1249 <MemberSignature Language="C#" Value="public Converter<string,string> MessageLocalizer { get; }" />
1250 <MemberSignature Language="ILAsm" Value=".property instance class System.Converter`2<string, string> MessageLocalizer" />
1251 <MemberType>Property</MemberType>
1253 <AssemblyVersion>0.2.3.0</AssemblyVersion>
1256 <ReturnType>System.Converter<System.String,System.String></ReturnType>
1260 Permits access to the message localization facility.
1263 A <see cref="T:System.Converter{System.String,System.String}" />
1264 that can be used to localize messages.
1270 <Member MemberName="Out">
1271 <MemberSignature Language="C#" Value="public System.IO.TextWriter Out { get; }" />
1272 <MemberSignature Language="ILAsm" Value=".property instance class System.IO.TextWriter Out" />
1273 <MemberType>Property</MemberType>
1275 <AssemblyVersion>0.2.3.0</AssemblyVersion>
1278 <ReturnType>System.IO.TextWriter</ReturnType>
1282 Where <c>CommandSet</c> should write output messages.
1285 A <see cref="T:System.IO.TextWriter" /> where output messages will
1290 This value may be set by providing the <paramref name="output" />
1291 constructor parameter. If not specified, then
1292 <see cref="P:System.Console.Out" /> will be used.
1295 Output messages by <c>CommandSet</c> are written to the <c>Out</c>
1296 property. <c>Command</c> instances may also choose to write output
1297 messages to the <c>CommandSet.Out</c> property. This is suggested
1298 to help with unit testing.
1303 <Member MemberName="Run">
1304 <MemberSignature Language="C#" Value="public int Run (System.Collections.Generic.IEnumerable<string> arguments);" />
1305 <MemberSignature Language="ILAsm" Value=".method public hidebysig instance int32 Run(class System.Collections.Generic.IEnumerable`1<string> arguments) cil managed" />
1306 <MemberType>Method</MemberType>
1308 <AssemblyVersion>0.2.3.0</AssemblyVersion>
1311 <ReturnType>System.Int32</ReturnType>
1314 <Parameter Name="arguments" Type="System.Collections.Generic.IEnumerable<System.String>" />
1317 <param name="arguments">
1318 A <see cref="T:System.Collections.Generic.IEnumerable{System.String}" />
1319 containing the command-line arguments to process.
1322 Processes command-line arguments and invokes the specified command.
1325 A <see cref="T:System.Int32" /> containing the command's exit value.
1326 Normal Unix process exit values should be used: <c>0</c> for success,
1327 non-zero values for failures.
1331 Processes <paramref name="arguments" />, parsing global options in the first pass.
1332 The first unprocessed argument is treated as a command name, and the
1333 <see cref="T:Mono.Options.Command" /> instance with a
1334 <see cref="P:Mono.Options.Command.Name" /> value matching the command name
1335 has its <see cref="M:Mono.Options.Command.Invoke" /> method invoked with the
1336 unprocessed arguments.
1338 <block subset="none" type="behaviors">
1340 If no command is specified within <paramref name="arguments" /><i>or</i> an invalid command name is specified, then <c>1</c> is returned.
1341 Otherwise, the value returned from
1342 <see cref="M:Mono.Options.Command.Invoke" /> is returned.
1346 If the <c>help</c> command is provided with no arguments, then the
1347 suite help text will be written to
1348 <see cref="P:Mono.Options.CommandSet.Out" />
1349 consisting of the descriptive text ("headers"), options, and
1350 <c>Command</c> values provided to
1351 <see cref="M:Mono.Options.CommandSet.Add" />.
1354 If the <c>help</c> command is provided with <c>--help</c> as an
1355 argument, then all registered <c>Command</c> instances are written to
1356 <see cref="P:Mono.Options.CommandSet.Out" />.
1359 If the <c>help</c> command is provided with any other string, the
1360 following value is treated as a command name, and the output of
1361 <c>command --help</c> is written to
1362 <see cref="P:Mono.Options.CommandSet.Out" />. If the specified
1363 command name has not been registered, then an error message is written to
1364 <see cref="P:Mono.Options.CommandSet.Error" />.
1369 <Member MemberName="Suite">
1370 <MemberSignature Language="C#" Value="public string Suite { get; }" />
1371 <MemberSignature Language="ILAsm" Value=".property instance string Suite" />
1372 <MemberType>Property</MemberType>
1374 <AssemblyVersion>0.2.3.0</AssemblyVersion>
1377 <ReturnType>System.String</ReturnType>
1381 The name of the suite.
1384 A <see cref="T:System.String" /> containing the name of the command suite.
1388 The <c>Suite</c> value is used when no command is specified, or
1389 when an unregistered command name is provided.