Add response file suport to Mono.Options.
[mono.git] / mcs / class / Mono.Options / Documentation / en / Mono.Options / OptionSet.xml
1 <Type Name="OptionSet" FullName="Mono.Options.OptionSet">
2   <TypeSignature Language="C#" Value="public class OptionSet : System.Collections.ObjectModel.KeyedCollection&lt;string,Mono.Options.Option&gt;" />
3   <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit OptionSet extends System.Collections.ObjectModel.KeyedCollection`2&lt;string, class Mono.Options.Option&gt;" />
4   <AssemblyInfo>
5     <AssemblyName>Mono.Options</AssemblyName>
6     <AssemblyVersion>0.2.0.0</AssemblyVersion>
7     <AssemblyVersion>0.2.1.0</AssemblyVersion>
8     <AssemblyVersion>0.2.2.0</AssemblyVersion>
9   </AssemblyInfo>
10   <ThreadingSafetyStatement>
11     All public static members of this type are safe for multithreaded
12     operations.  The 
13     <see cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable&lt;System.String&gt;)" />
14     instance method is thread-safe if no concurrent modifying methods are
15     invoked 
16     (<see cref="M:Mono.Options.OptionSet.Add(Mono.Options.Option)" />,
17     <see cref="M:System.Collections.ObjectModel.Collection{Mono.Options.Option}.Remove(``0)" />,
18     etc.).
19   </ThreadingSafetyStatement>
20   <Base>
21     <BaseTypeName>System.Collections.ObjectModel.KeyedCollection&lt;System.String,Mono.Options.Option&gt;</BaseTypeName>
22     <BaseTypeArguments>
23       <BaseTypeArgument TypeParamName="!0">System.String</BaseTypeArgument>
24       <BaseTypeArgument TypeParamName="!1">Mono.Options.Option</BaseTypeArgument>
25     </BaseTypeArguments>
26   </Base>
27   <Interfaces />
28   <Docs>
29     <summary>
30       A class to parse program options.
31     </summary>
32     <remarks>
33       <para>
34         A common requirement for command-line programs is option parsing.  
35         The command line consists of a sequence of 
36         <paramref name="arguments" />.  
37         <see cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />
38         parses this argument
39         sequence, invoking actions of registered 
40         <see cref="T:Mono.Options.Option" />s when a sequence of arguments 
41         matching the <see cref="T:Mono.Options.Option" />s requirements are
42         encountered.  <see cref="T:Mono.Options.Option" />'s are registered 
43         with <see cref="M:Mono.Options.OptionSet.Add(Mono.Options.Option)" />
44         and its overloads.
45       </para>
46       <para>
47         <see cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />,
48         returns a 
49         <see cref="T:System.Collections.Generic.List{System.String}" /> of all
50         arguments which were not matched by a registered
51         <see cref="T:Mono.Options.Option" />.
52       </para>
53       <para>
54         Response files, as used by <c>mcs</c> and other compiler tools, may be
55         supported by using <see cref="T:Mono.Options.ResponseFileSource" />.
56       </para>
57       <para>
58         Three conditions must be met for a sequence of arguments to be
59         considered as a match for an <see cref="T:Mono.Options.Option" />:
60       </para>
61       <list type="bullet">
62         <item>
63           <term>
64           The <paramref name="name" /> must be matched.  An 
65           <see cref="T:Mono.Options.Option" /> has one or more names, as
66           returned from <see cref="M:Mono.Options.Option.GetNames" />.
67           Matched names must start with a <paramref name="flag" /> 
68           (even though the flag is not part of the
69           <see cref="P:Mono.Options.Option.Prototype" />): <c>-</c>, 
70           <c>--</c>, or <c>/</c>.
71           There are several different name matching algorithms:
72           <list type="bullet"><item><term><para><paramref name="Simple" /> names are matched when the argument
73                 consists solely of a flag followed by an option name.
74               </para><para>
75                 Examples: <c>-opt</c>, <c>--opt</c>, and <c>/opt</c> are all
76                 simple names for the <c>opt</c> option.
77               </para></term></item><item><term><para><paramref name="Boolean" /> names are matched when the
78                 argument consists of a flag, followed by an option name,
79                 followed by <c>+</c> or <c>-</c>.  If a <c>+</c> follows the
80                 name, the option is enabled, otherwise the option is disabled.
81               </para><para>
82                 Examples: <c>-opt+</c> and <c>-opt-</c> enable and disble the
83                 <c>opt</c> option.
84               </para></term></item><item><term><para><paramref name="Assigned" /> names are matched when the
85                 argument consists of a flag, followed by an option name,
86                 followed by a <c>=</c> or <c>:</c>, followed by an (optional)
87                 string.
88               </para><para>
89                 Examples: <c>-opt=A</c>, <c>--opt:B</c>, and <c>/opt=C</c> all
90                 provide a value for the <c>opt</c> option.
91               </para></term></item><item><term><para><paramref name="Bundled" /> names are matched only when
92                 simple, boolean, and assigned names are not matched,
93                 the flag is <c>-</c>, and the first character matches a
94                 registered option.  Any number of (single-character) boolean 
95                 options may be bundled in this fashion, and at most one
96                 <see cref="F:Mono.Options.OptionValueType.Optional" /> or
97                 <see cref="F:Mono.Options.OptionValueType.Required" /> option 
98                 (which will use all remaining characters within the argument
99                 as a value).
100               </para><para>
101                 Examples: <c>-xvfinput-file</c> could match the boolean 
102                 <see cref="T:Mono.Options.Option" />s <c>x</c> and <c>v</c>
103                 and the value-accepting option <c>f</c>, which will get the
104                 value <c>input-file</c>.  (Other interpretations are also
105                 possible, depending upon which options are registered.)
106               </para></term></item><item><term><para>
107                   As a fallback, a <paramref name="default handler" /> may be
108                   registered which will handle <paramref name="all" />
109                   arguments which are not handled by any of the above matching
110                   algorithms.  The default handler is designated by the name
111                   <c>&lt;&gt;</c> (which may be an alias for another named
112                   <see cref="T:Mono.Options.Option" />).
113                 </para><para>
114                   Default handlers are useful for argument runs -- sequences
115                   of arguments that are not related to each other but are
116                   instead related to a prior option on the command line, and it
117                   isn't desirable to use named options for these.  For
118                   example, <c>mdoc-assemble --format=ecma DirA DirB 
119                   --format=man FileC</c> would process <c>DirA</c> and
120                   <c>DirB</c> with <c>--format=ecma</c> in effect, and then
121                   process <c>FileC</c> with <c>--format=man</c> in effect.
122                 </para><para>
123                   See 
124                   <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
125                   for additional details regarding default option handlers.
126                 </para></term></item></list></term>
127         </item>
128         <item>
129           <term>
130           The <paramref name="type" /> must be matched.  
131           <see cref="P:Mono.Options.Option.OptionValueType" /> specifies the
132           option's type.  See below for more information.
133         </term>
134         </item>
135         <item>
136           <term>
137           The <paramref name="value count" /> must be matched.  Whether an
138           option takes any values is dependent upon the option's type
139           (previous bullet), but the number of values the option either
140           accepts or requires is specified by the
141           <see cref="P:Mono.Options.Option.MaxValueCount" /> property.
142         </term>
143         </item>
144       </list>
145       <para>
146         There are three types of <see cref="T:Mono.Options.Option" />s that
147         can be parsed:
148       </para>
149       <list type="number">
150         <item>
151           <term>
152           Boolean options, which correspond to a 
153           <see cref="P:Mono.Options.Option.OptionValueType" /> value of
154           <see cref="F:Mono.Options.OptionValueType.None" />.
155           When a matching argument is encountered, their registered
156           action is invoked immediately.  The <see cref="T:System.Action`1" />
157           value will be non-<see langword="default(T)" /> if the value is true,
158           e.g.  if <c>-option</c> or <c>-option+</c> is specified, and the value
159           will be <see langword="default(T)" /> if the value is false, e.g. 
160           if <c>-option-</c> is specified.
161         </term>
162         </item>
163         <item>
164           <term>
165             <para>
166             Optional value options, which correspond to a 
167             <see cref="P:Mono.Options.Option.OptionValueType" /> value of
168             <see cref="F:Mono.Options.OptionValueType.Optional" />.
169             Optional value options are not "greedy"; they will only get their
170             value only from the current argument.  If the value is not present, 
171             <see langword="default(T)" /> is provided to their corresponding
172             <see cref="T:System.Action`1" />.
173           </para>
174             <para>
175             Thus, <c>-opt:value</c> would pass <c>value</c> to the
176             action registered for <c>opt</c>, while <c>-opt value</c> would pass
177             <see langword="default(T)" /> to the action registered for 
178             <c>opt</c> and <c>value</c> would be an unparsed argument.
179           </para>
180           </term>
181         </item>
182         <item>
183           <term>
184             <para>
185             Required value options, which correspond to a 
186             <see cref="P:Mono.Options.Option.OptionValueType" /> value of
187             <see cref="F:Mono.Options.OptionValueType.Required" />.
188             Required value options are "greedy" -- if the value is not found
189             within the current argument, the following argument(s) will be used to
190             supply the value(s).  Once enough values have been parsed, 
191             their corresponding <see cref="T:System.Action`1" /> is invoked.
192           </para>
193             <para>
194             Thus, both <c>-opt:value</c> and <c>-opt value</c> would pass 
195             <c>value</c> to the action registered for <c>opt</c>.
196           </para>
197             <para>
198             If no value can be found, an 
199             <see cref="T:Mono.Options.OptionException" /> is thrown from
200             <see cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />.
201           </para>
202           </term>
203         </item>
204       </list>
205       <block subset="none" type="behaviors">
206         <para>
207           Use of <c>OptionSet</c> is split up into two parts:
208         </para>
209         <list type="number">
210           <item>
211             <term>Initialization.</term>
212           </item>
213           <item>
214             <term>Parsing.</term>
215           </item>
216         </list>
217         <para>
218           During the <paramref name="initialization" /> phase, new
219           <see cref="T:Mono.Options.Option" /> instances are created and
220           associated with an action to perform when the <c>Option</c>
221           requirements are met (e.g. when a required value has been
222           encountered).  This phase is not thread safe.
223           All options added during this phase are considered to have been
224           <paramref name="registered" />.
225         </para>
226         <code lang="C#">OptionSet p = new OptionSet () {
227   { "option-a", v =&gt; { /* action to perform */ } },
228 };</code>
229         <para>
230           There are three ways to add <see cref="T:Mono.Options.Option" />s
231           to the <see cref="T:Mono.Options.OptionSet" />:
232         </para>
233         <list type="number">
234           <item>
235             <term>
236             With C# collection initializers, as used above.
237           </term>
238           </item>
239           <item>
240             <term>
241             Explicitly by calling
242             <see cref="M:Mono.Options.OptionSet.Add(System.String,System.Action{System.String})" />
243             and the other <c>Add</c> overloads.
244           </term>
245           </item>
246           <item>
247             <term>
248             By creating a new subclass of <see cref="T:Mono.Options.Option" />
249             and adding it via 
250             <see cref="M:Mono.Options.OptionSet.Add(Mono.Options.Option)" />.
251             This is not recommended, but is available if you require more
252             direct option handling than the default 
253             <see cref="T:Mono.Options.Option" /> implementation provides.
254           </term>
255           </item>
256         </list>
257         <para>
258           During the <paramref name="parsing" /> phase, an
259           <see cref="T:System.Collections.Generic.IEnumerable{System.String}" />
260           is enumerated, looking for arguments which match a registered option,
261           and invoking the corresponding action when an option and associated
262           (optional) value is encountered.  During this phase, the 
263           <see cref="T:Mono.Options.OptionSet" /> instance itself is thread
264           safe, but full thread safety depends upon thread-safety of the
265           registered actions.  Any option-like strings for names that haven't
266           been registered, e.g. <c>--this-was-never-registered=false</c>, and
267           all arguments that are not used as option values are returned from 
268           <see cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />
269           or processed by the default handler <c>&lt;&gt;</c>, if registered.
270         </para>
271         <code lang="C#">List&lt;string&gt; extra = p.Parse (new string[]{"-option-a"});</code>
272       </block>
273       <block subset="none" type="overrides">
274         <para>
275           Subclasses can override the following <see langword="virtual" /> 
276           methods to customize option parsing behavior:
277         </para>
278         <list type="bullet">
279           <item>
280             <term>
281               <see cref="M:Mono.Options.OptionSet.Parse(System.String,Mono.Options.OptionContext)" />
282             </term>
283           </item>
284           <item>
285             <term>
286               <see cref="M:Mono.Options.OptionSet.CreateOptionContext" />
287             </term>
288           </item>
289         </list>
290       </block>
291     </remarks>
292     <example>
293       <para>
294         The following example demonstrates some simple usage of 
295         <see cref="T:Mono.Options.OptionSet" />.
296       </para>
297       <code lang="C#" src="examples/greet.cs">using System;
298 using System.Collections.Generic;
299 using NDesk.Options;
300
301 class Test {
302         static int verbosity;
303
304         public static void Main (string[] args)
305         {
306                 bool show_help = false;
307                 List&lt;string&gt; names = new List&lt;string&gt; ();
308                 int repeat = 1;
309
310                 var p = new OptionSet () {
311                         { "n|name=", "the {NAME} of someone to greet.",
312                           v =&gt; names.Add (v) },
313                         { "r|repeat=", 
314                                 "the number of {TIMES} to repeat the greeting.\n" + 
315                                         "this must be an integer.",
316                           (int v) =&gt; repeat = v },
317                         { "v", "increase debug message verbosity",
318                           v =&gt; { if (v != null) ++verbosity; } },
319                         { "h|help",  "show this message and exit", 
320                           v =&gt; show_help = v != null },
321                 };
322
323                 List&lt;string&gt; extra;
324                 try {
325                         extra = p.Parse (args);
326                 }
327                 catch (OptionException e) {
328                         Console.Write ("greet: ");
329                         Console.WriteLine (e.Message);
330                         Console.WriteLine ("Try `greet --help' for more information.");
331                         return;
332                 }
333
334                 if (show_help) {
335                         ShowHelp (p);
336                         return;
337                 }
338
339                 string message;
340                 if (extra.Count &gt; 0) {
341                         message = string.Join (" ", extra.ToArray ());
342                         Debug ("Using new message: {0}", message);
343                 }
344                 else {
345                         message = "Hello {0}!";
346                         Debug ("Using default message: {0}", message);
347                 }
348
349                 foreach (string name in names) {
350                         for (int i = 0; i &lt; repeat; ++i)
351                                 Console.WriteLine (message, name);
352                 }
353         }
354
355         static void ShowHelp (OptionSet p)
356         {
357                 Console.WriteLine ("Usage: greet [OPTIONS]+ message");
358                 Console.WriteLine ("Greet a list of individuals with an optional message.");
359                 Console.WriteLine ("If no message is specified, a generic greeting is used.");
360                 Console.WriteLine ();
361                 Console.WriteLine ("Options:");
362                 p.WriteOptionDescriptions (Console.Out);
363         }
364
365         static void Debug (string format, params object[] args)
366         {
367                 if (verbosity &gt; 0) {
368                         Console.Write ("# ");
369                         Console.WriteLine (format, args);
370                 }
371         }
372 }
373
374 </code>
375       <para>The output (under the influence of different command-line
376         arguments) is:</para>
377       <code lang="sh" src="examples/greet.txt">$ mono greet.exe --help
378 Usage: greet [OPTIONS]+ message
379 Greet a list of individuals with an optional message.
380 If no message is specified, a generic greeting is used.
381
382 Options:
383   -n, --name=NAME            the NAME of someone to greet.
384   -r, --repeat=TIMES         the number of TIMES to repeat the greeting.
385                                this must be an integer.
386   -v                         increase debug message verbosity
387   -h, --help                 show this message and exit
388
389 $ mono greet.exe -v- -n A -name=B --name=C /name D -nE
390 Hello A!
391 Hello B!
392 Hello C!
393 Hello D!
394 Hello E!
395
396 $ mono greet.exe -v -n E custom greeting for: {0}
397 # Using new message: custom greeting for: {0}
398 custom greeting for: E
399
400 $ mono greet.exe -r 3 -n A
401 Hello A!
402 Hello A!
403 Hello A!
404
405 $ mono greet.exe -r not-an-int
406 greet: Could not convert string `not-an-int' to type Int32 for option `-r'.
407 Try `greet --help' for more information.
408 </code>
409       <para>
410         Notice how the output produced by <c>--help</c> uses the
411         descriptions provided during <c>OptionSet</c> initialization.
412         Notice that the <see cref="T:Mono.Options.Option" /> requiring a 
413         value (<c>n|name=</c>) can use multiple different forms of invocation,
414         including: 
415         <c>-n value</c>, 
416         <c>-n=value</c>, 
417         <c>-name value</c>, 
418         <c>-name=value</c>, 
419         <c>--name value</c>,
420         <c>--name=value</c>,
421         <c>/name value</c>, and
422         <c>/name=value</c>.
423       </para>
424       <para>
425         Notice also that the boolean <c>v</c> option can take three
426         separate forms: <c>-v</c> and <c>-v+</c>, which both enable the option,
427         and <c>-v-</c>, which disables the option.  (The second <c>greet</c>
428         invocation uses <c>-v-</c>, which is why no debug messages are shown.)
429       </para>
430       <para>
431         Finally, note that the action can specify a type to use.  If no type
432         is provided, the action parameter will be a 
433         <see cref="T:System.String" />.  If a type is provided, then
434         <see cref="T:System.ComponentModel.TypeConverter" /> will be used to
435         convert a string to the specified type.
436       </para>
437     </example>
438     <example>
439       <para>
440         The following example shows how options and values can be bundled
441         together.
442       </para>
443       <code lang="C#" src="examples/bundling.cs">using System;
444 using System.Linq;
445 using System.Collections.Generic;
446 using NDesk.Options;
447
448 class Test {
449         public static void Main (string[] args)
450         {
451                 var show_help = false;
452                 var macros = new Dictionary&lt;string, string&gt;();
453                 bool create = false, extract = false, list = false;
454                 string output = null, input = null;
455                 string color  = null;
456
457                 var p = new OptionSet () {
458                         // gcc-like options
459                         { "D:", "Predefine a macro with an (optional) value.",
460                                 (m, v) =&gt; {
461                                         if (m == null)
462                                                 throw new OptionException ("Missing macro name for option -D.", 
463                                                                 "-D");
464                                         macros.Add (m, v);
465                                 } },
466                         { "d={--&gt;}{=&gt;}", "Alternate macro syntax.", 
467                                 (m, v) =&gt; macros.Add (m, v) },
468                         { "o=", "Specify the output file", v =&gt; output = v },
469
470                         // tar-like options
471                         { "f=", "The input file",   v =&gt; input = v },
472                         { "x",  "Extract the file", v =&gt; extract = v != null },
473                         { "c",  "Create the file",  v =&gt; create = v != null },
474                         { "t",  "List the file",    v =&gt; list = v != null },
475
476                         // ls-like optional values
477                         { "color:", "control whether and when color is used", 
478                                 v =&gt; color = v },
479
480                         // other...
481                         { "h|help",  "show this message and exit", 
482                           v =&gt; show_help = v != null },
483                         // default
484                         { "&lt;&gt;",
485                                 v =&gt; Console.WriteLine ("def handler: color={0}; arg={1}", color, v)},
486                 };
487
488                 try {
489                         p.Parse (args);
490                 }
491                 catch (OptionException e) {
492                         Console.Write ("bundling: ");
493                         Console.WriteLine (e.Message);
494                         Console.WriteLine ("Try `greet --help' for more information.");
495                         return;
496                 }
497
498                 if (show_help) {
499                         ShowHelp (p);
500                         return;
501                 }
502
503                 Console.WriteLine ("Macros:");
504                 foreach (var m in (from k in macros.Keys orderby k select k)) {
505                         Console.WriteLine ("\t{0}={1}", m, macros [m] ?? "&lt;null&gt;");
506                 }
507                 Console.WriteLine ("Options:");
508                 Console.WriteLine ("\t Input File: {0}", input);
509                 Console.WriteLine ("\tOuptut File: {0}", output);
510                 Console.WriteLine ("\t     Create: {0}", create);
511                 Console.WriteLine ("\t    Extract: {0}", extract);
512                 Console.WriteLine ("\t       List: {0}", list);
513                 Console.WriteLine ("\t      Color: {0}", color ?? "&lt;null&gt;");
514         }
515
516         static void ShowHelp (OptionSet p)
517         {
518                 Console.WriteLine ("Usage: bundling [OPTIONS]+");
519                 Console.WriteLine ("Demo program to show the effects of bundling options and their values");
520                 Console.WriteLine ();
521                 Console.WriteLine ("Options:");
522                 p.WriteOptionDescriptions (Console.Out);
523         }
524 }
525
526 </code>
527       <para>
528         The output (under the influence of different command-line arguments) is:
529       </para>
530       <code lang="sh" src="examples/bundling.txt">$ mono bundling.exe --help
531 Usage: bundling [OPTIONS]+
532 Demo program to show the effects of bundling options and their values
533
534 Options:
535   -D[=VALUE1:VALUE2]         Predefine a macro with an (optional) value.
536   -d=VALUE1--&gt;VALUE2         Alternate macro syntax.
537   -o=VALUE                   Specify the output file
538   -f=VALUE                   The input file
539   -x                         Extract the file
540   -c                         Create the file
541   -t                         List the file
542       --color[=VALUE]        control whether and when color is used
543   -h, --help                 show this message and exit
544
545 $ mono bundling.exe -D
546 bundling: Missing macro name for option -D.
547 Try `greet --help' for more information.
548
549 $ mono bundling.exe -DA -DB=C "-dD--&gt;E" "-dF=&gt;G" -d "H=&gt;I" -cf input --color -ooutput
550 Macros:
551         A=&lt;null&gt;
552         B=C
553         D=E
554         F=G
555         H=I
556 Options:
557          Input File: input
558         Ouptut File: output
559              Create: True
560             Extract: False
561                List: False
562               Color: &lt;null&gt;
563
564 $ mono bundling.exe -cfv input
565 def handler: color=; arg=input
566 Macros:
567 Options:
568          Input File: v
569         Ouptut File: 
570              Create: True
571             Extract: False
572                List: False
573               Color: &lt;null&gt;
574
575 $ mono bundling.exe -xctf input
576 Macros:
577 Options:
578          Input File: input
579         Ouptut File: 
580              Create: True
581             Extract: True
582                List: True
583               Color: &lt;null&gt;
584
585 $ mono bundling.exe --color=auto -o output -finput
586 Macros:
587 Options:
588          Input File: input
589         Ouptut File: output
590              Create: False
591             Extract: False
592                List: False
593               Color: auto
594
595 $ mono bundling.exe --color=on A B --color=off C D
596 def handler: color=on; arg=A
597 def handler: color=on; arg=B
598 def handler: color=off; arg=C
599 def handler: color=off; arg=D
600 Macros:
601 Options:
602          Input File: 
603         Ouptut File: 
604              Create: False
605             Extract: False
606                List: False
607               Color: off
608 </code>
609     </example>
610     <example>
611       <para>
612         The following example shows a custom <c>OptionSet</c> subclass with
613         the following additional functionality:
614       </para>
615       <list type="number">
616         <item>
617           <term>
618           Option name lookup is done in a case insensitive fashion, so
619           <c>--name</c> and <c>--NAME</c> are identical.
620         </term>
621         </item>
622         <item>
623           <term>
624           Option-like strings cannot be used as values to options, so
625           <c>--name --repeat</c> is an error.
626         </term>
627         </item>
628         <item>
629           <term>
630           A key/value parser is provided, to show the use of custom 
631           <see cref="T:Mono.Options.OptionContext" /> and
632           <see cref="T:Mono.Options.Option" /> subclasses.
633         </term>
634         </item>
635       </list>
636       <code lang="C#" src="examples/subclass.cs">// Case-Insensitive and Concatenating OptionSet
637 using System;
638 using System.Collections.Generic;
639 using NDesk.Options;
640
641 class DemoOptionSet : OptionSet {
642         protected override void InsertItem (int index, Option item)
643         {
644                 if (item.Prototype.ToLower () != item.Prototype)
645                         throw new ArgumentException ("prototypes must be lower-case!");
646                 base.InsertItem (index, item);
647         }
648
649         protected override OptionContext CreateOptionContext ()
650         {
651                 return new OptionContext (this);
652         }
653
654         protected override bool Parse (string option, OptionContext c)
655         {
656                 string f, n, s, v;
657                 bool haveParts = GetOptionParts (option, out f, out n, out s, out v);
658                 Option nextOption = null;
659                 string newOption  = option;
660
661                 if (haveParts) {
662                         string nl = n.ToLower ();
663                         nextOption = Contains (nl) ? this [nl] : null;
664                         newOption = f + n.ToLower () + (v != null ? s + v : "");
665                 }
666
667                 if (c.Option != null) {
668                         // Prevent --a --b
669                         if (c.Option != null &amp;&amp; haveParts) {
670                                 if (nextOption == null) {
671                                         // ignore
672                                 }
673                                 else 
674                                         throw new OptionException (
675                                                 string.Format ("Found option `{0}' as value for option `{1}'.",
676                                                         option, c.OptionName), c.OptionName);
677                         }
678
679                         // have a option w/ required value; try to concat values.
680                         if (AppendValue (option, c)) {
681                                 if (!option.EndsWith ("\\") &amp;&amp; 
682                                                 c.Option.MaxValueCount == c.OptionValues.Count) {
683                                         c.Option.Invoke (c);
684                                 }
685                                 return true;
686                         }
687                         else
688                                 base.Parse (newOption, c);
689                 }
690
691                 if (!haveParts || v == null) {
692                         // Not an option; let base handle as a non-option argument.
693                         return base.Parse (newOption, c);
694                 }
695
696                 if (nextOption.OptionValueType != OptionValueType.None &amp;&amp; 
697                                 v.EndsWith ("\\")) {
698                         c.Option = nextOption;
699                         c.OptionValues.Add (v);
700                         c.OptionName = f + n;
701                         return true;
702                 }
703
704                 return base.Parse (newOption, c);
705         }
706
707         private bool AppendValue (string value, OptionContext c)
708         {
709                 bool added = false;
710                 string[] seps = c.Option.GetValueSeparators ();
711                 foreach (var o in seps.Length != 0
712                                 ? value.Split (seps, StringSplitOptions.None)
713                                 : new string[]{value}) {
714                         int idx = c.OptionValues.Count-1;
715                         if (idx == -1 || !c.OptionValues [idx].EndsWith ("\\")) {
716                                 c.OptionValues.Add (o);
717                                 added = true;
718                         }
719                         else {
720                                 c.OptionValues [idx] += value;
721                                 added = true;
722                         }
723                 }
724                 return added;
725         }
726 }
727
728 class Demo {
729         public static void Main (string[] args)
730         {
731                 List&lt;string&gt; names = new List&lt;string&gt; ();
732                 Dictionary&lt;string,string&gt; map = new Dictionary&lt;string,string&gt; ();
733                 int repeat = 1;
734
735                 OptionSet p = new DemoOptionSet () {
736                         { "n|name=",    v =&gt; names.Add (v) },
737                         { "r|repeat:",  (int v) =&gt; repeat = v },
738                         { "m|map=",     (k,v) =&gt; map.Add (k, v) },
739                 };
740
741                 List&lt;string&gt; extra;
742                 try {
743                         extra = p.Parse (args);
744                 }
745                 catch (OptionException e) {
746                         Console.Write ("subclass: ");
747                         Console.WriteLine (e.Message);
748                         return;
749                 }
750
751                 string message;
752                 if (extra.Count &gt; 0) {
753                         message = string.Join (" ", extra.ToArray ());
754                 }
755                 else {
756                         message = "Hello {0}!";
757                 }
758
759                 foreach (string name in names) {
760                         for (int i = 0; i &lt; repeat; ++i)
761                                 Console.WriteLine (message, name);
762                 }
763                 List&lt;string&gt; keys = new List&lt;string&gt;(map.Keys);
764                 keys.Sort ();
765                 foreach (string key in keys) {
766                         Console.WriteLine ("Key: {0}={1}", key, map [key]);
767                 }
768         }
769 }
770
771 </code>
772       <para>The output (under the influence of different command-line
773         arguments) is:
774       </para>
775       <code lang="sh" src="examples/subclass.txt">$ mono subclass.exe -n A -Name=B --NAME=C /nAMe D
776 Hello A!
777 Hello B!
778 Hello C!
779 Hello D!
780
781 $ mono subclass.exe --Repeat -name A
782
783 $ mono subclass.exe -Name --Repeat 3
784 subclass: Found option `--Repeat' as value for option `-name'.
785
786 $ mono subclass.exe --Map a b -mAp c=d /maP=e=f
787 Key: a=b
788 Key: c=d
789 Key: e=f
790
791 $ mono subclass.exe --map 'a\' 'b\' c 'd\' 'e\' f
792 Key: a\b\c=d\e\f
793 </code>
794       <para>Notice:</para>
795       <list type="bullet">
796         <item>
797           <term>
798           That <c>--name</c> is treated in a case-insensitive fashion.
799         </term>
800         </item>
801         <item>
802           <term>
803           That <c>repeat</c> has an optional value, so with 
804           <c>--Repeat -name A</c> the default <c>int</c> value is passed (0),
805           so no message is printed.
806         </term>
807         </item>
808         <item>
809           <term>
810           That <c>name</c> has a required value, so 
811           <c>-Name --Repeat 3</c> generates an error.
812         </term>
813         </item>
814         <item>
815           <term>
816           The <c>DemoOptionSet.Add()</c> method provides appropriate key/value
817           option pairs to the callback method.
818         </term>
819         </item>
820       </list>
821     </example>
822     <altmember cref="T:Mono.Options.ResponseFileSource" />
823   </Docs>
824   <Members>
825     <Member MemberName=".ctor">
826       <MemberSignature Language="C#" Value="public OptionSet ();" />
827       <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
828       <MemberType>Constructor</MemberType>
829       <AssemblyInfo>
830         <AssemblyVersion>0.2.0.0</AssemblyVersion>
831         <AssemblyVersion>0.2.1.0</AssemblyVersion>
832         <AssemblyVersion>0.2.2.0</AssemblyVersion>
833       </AssemblyInfo>
834       <Parameters />
835       <Docs>
836         <summary>
837           Creates and initializes a new 
838           <see cref="T:Mono.Options.OptionSet" /> class instance.
839         </summary>
840         <remarks>
841           <para>
842             This constructor causes the created 
843             <see cref="T:Mono.Options.OptionSet" /> instance to perform no
844             translation of string messages; consequently, no localization is
845             performed.
846           </para>
847         </remarks>
848         <altmember cref="C:Mono.Options.OptionSet(System.Converter{System.String,System.String})" />
849       </Docs>
850     </Member>
851     <Member MemberName=".ctor">
852       <MemberSignature Language="C#" Value="public OptionSet (Converter&lt;string,string&gt; localizer);" />
853       <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(class System.Converter`2&lt;string, string&gt; localizer) cil managed" />
854       <MemberType>Constructor</MemberType>
855       <AssemblyInfo>
856         <AssemblyVersion>0.2.0.0</AssemblyVersion>
857         <AssemblyVersion>0.2.1.0</AssemblyVersion>
858         <AssemblyVersion>0.2.2.0</AssemblyVersion>
859       </AssemblyInfo>
860       <Parameters>
861         <Parameter Name="localizer" Type="System.Converter&lt;System.String,System.String&gt;" />
862       </Parameters>
863       <Docs>
864         <param name="localizer">
865           A <see cref="T:System.Converter{System.String,System.String}" />
866           instance that will be used to translate strings.
867         </param>
868         <summary>
869           Creates and initializes a new 
870           <see cref="T:Mono.Options.OptionSet" /> class instance.
871         </summary>
872         <remarks>
873           <para>
874             This constructor initializes the 
875             <see cref="P:Mono.Options.OptionSet.MessageLocalizer" /> property
876             of the new instance using <paramref name="localizer" />.
877           </para>
878           <para>
879             Use this constructor when you want to perform some form of
880             localization or internationalization on text strings generated
881             from the <see cref="T:Mono.Options.OptionSet" /> class.
882             Generated strings include:
883           </para>
884           <list type="bullet">
885             <item>
886               <term>
887               The <see cref="P:Mono.Options.Option.Description" /> written by
888               <see cref="M:Mono.Options.OptionSet.WriteOptionDescriptions(System.IO.TextWriter)" />,
889               but not the option names themselves.
890             </term>
891             </item>
892             <item>
893               <term>
894               Message format strings used when an error is encountered.
895             </term>
896             </item>
897           </list>
898         </remarks>
899         <example>
900           <para>
901             See the following example, which demonstrates how different
902             localizers alter the program output.
903           </para>
904           <code lang="C#" src="examples/localization.cs">// Localization with NDesk.Options.OptionSet.
905 //
906 // Compile as:
907 //   gmcs -r:Mono.Posix.dll -r:NDesk.Options.dll code-localization.cs
908 using System;
909 using System.IO;
910 using Mono.Unix;
911 using NDesk.Options;
912
913 class LocalizationDemo {
914         public static void Main (string[] args)
915         {
916                 bool with_gettext = false;
917                 string useLocalizer = null;
918                 var p = new OptionSet () {
919                         { "with-gettext", v =&gt; { useLocalizer = "gettext"; } },
920                         { "with-hello",   v =&gt; { useLocalizer = "hello"; } },
921                         { "with-default", v =&gt; { /* do nothing */ } },
922                 };
923                 p.Parse (args);
924
925                 Converter&lt;string, string&gt; localizer = f =&gt; f;
926                 switch (useLocalizer) {
927                         case "gettext":
928                                 Catalog.Init ("localization", 
929                                                 Path.Combine (AppDomain.CurrentDomain.BaseDirectory,
930                                                         "locale"));
931                                 localizer = f =&gt; { return Catalog.GetString (f); };
932                                 break;
933                         case "hello":
934                                 localizer = f =&gt; { return "hello:" + f; };;
935                                 break;
936                 }
937
938                 bool help = false;
939                 int verbose = 0;
940                 bool version = false;
941                 p = new OptionSet (localizer) {
942                         { "h|?|help", "show this message and exit.", 
943                                 v =&gt; help = v != null },
944                         { "v|verbose", "increase message verbosity.",
945                                 v =&gt; { ++verbose; } },
946                         { "n=", "must be an int",
947                                 (int n) =&gt; { /* ignore */ } },
948                         { "V|version", "output version information and exit.",
949                                 v =&gt; version = v != null },
950                 };
951                 try {
952                         p.Parse (args);
953                 }
954                 catch (OptionException e) {
955                         Console.Write ("localization: ");
956                         Console.WriteLine (e.Message);
957                         return;
958                 }
959                 if (help)
960                         p.WriteOptionDescriptions (Console.Out);
961                 if (version)
962                         Console.WriteLine ("NDesk.Options Localizer Demo 1.0");
963                 if (verbose &gt; 0)
964                         Console.WriteLine ("Message level: {0}", verbose);
965         }
966 }
967 </code>
968           <para>The output (under the influence of different command-line
969             arguments) is:</para>
970           <code lang="sh" src="examples/localization.txt">$ mono localization.exe --help --version
971   -h, -?, --help             show this message and exit.
972   -v, --verbose              increase message verbosity.
973   -n=VALUE                   must be an int
974   -V, --version              output version information and exit.
975 NDesk.Options Localizer Demo 1.0
976
977 $ LANGUAGE=es mono localization.exe --with-gettext --help --version
978   -h, -?, --help             A mostrar este mensaje y salir.
979   -v, --verbose              Aumento mensaje verbosidad.
980   -n=VALUE                   Debe ser un int
981   -V, --version              Salida de información de versión y sale.
982 NDesk.Options Localizer Demo 1.0
983
984 $ mono localization.exe --with-hello --help --version
985   -h, -?, --help             hello:show this message and exit.
986   -v, --verbose              hello:increase message verbosity.
987   -nhello:=VALUE             hello:must be an int
988   -V, --version              hello:output version information and exit.
989 NDesk.Options Localizer Demo 1.0
990
991 $ mono localization.exe -n not-an-int
992 localization: Could not convert string `not-an-int' to type Int32 for option `-n'.
993
994 $ mono localization.exe --with-hello -n not-an-int
995 localization: hello:Could not convert string `not-an-int' to type Int32 for option `-n'.
996 </code>
997           <para>Notice:</para>
998           <list type="bullet">
999             <item>
1000               <term>
1001               The <c>--with-gettext</c> parser uses 
1002               <see cref="M:Mono.Unix.Catalog.GetString" /> to translate all
1003               messages
1004             </term>
1005             </item>
1006             <item>
1007               <term>
1008               The <c>-with-hello</c> parser prefixes all 
1009               descriptions with <c>hello:</c>.
1010             </term>
1011             </item>
1012             <item>
1013               <term>
1014               Only the descriptions are translated, and not the command-line 
1015               arguments themselves.  Only error messages and 
1016               option descriptions are translated, not the options themselves.
1017             </term>
1018             </item>
1019           </list>
1020         </example>
1021       </Docs>
1022     </Member>
1023     <Member MemberName="Add">
1024       <MemberSignature Language="C#" Value="public Mono.Options.OptionSet Add (Mono.Options.ArgumentSource source);" />
1025       <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.OptionSet Add(class Mono.Options.ArgumentSource source) cil managed" />
1026       <MemberType>Method</MemberType>
1027       <AssemblyInfo>
1028         <AssemblyVersion>0.2.2.0</AssemblyVersion>
1029       </AssemblyInfo>
1030       <ReturnValue>
1031         <ReturnType>Mono.Options.OptionSet</ReturnType>
1032       </ReturnValue>
1033       <Parameters>
1034         <Parameter Name="source" Type="Mono.Options.ArgumentSource" />
1035       </Parameters>
1036       <Docs>
1037         <param name="source">
1038           A <see cref="T:Mono.Options.ArgumentSource" /> to register for
1039           argument processing.
1040         </param>
1041         <summary>
1042           Registers <paramref name="source" /> so that it may be consulted
1043           during argument processing within
1044           <see cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />.
1045         </summary>
1046         <returns>
1047           The current <see cref="T:Mono.Options.OptionSet" /> instance.
1048           This is to permit method chaining.
1049         </returns>
1050         <remarks>
1051         </remarks>
1052         <exception cref="T:System.ArgumentNullException">
1053           <paramref name="option" /> is <see langword="null" />.
1054         </exception>
1055       </Docs>
1056     </Member>
1057     <Member MemberName="Add">
1058       <MemberSignature Language="C#" Value="public Mono.Options.OptionSet Add (Mono.Options.Option option);" />
1059       <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.OptionSet Add(class Mono.Options.Option option) cil managed" />
1060       <MemberType>Method</MemberType>
1061       <AssemblyInfo>
1062         <AssemblyVersion>0.2.0.0</AssemblyVersion>
1063         <AssemblyVersion>0.2.1.0</AssemblyVersion>
1064         <AssemblyVersion>0.2.2.0</AssemblyVersion>
1065       </AssemblyInfo>
1066       <ReturnValue>
1067         <ReturnType>Mono.Options.OptionSet</ReturnType>
1068       </ReturnValue>
1069       <Parameters>
1070         <Parameter Name="option" Type="Mono.Options.Option" />
1071       </Parameters>
1072       <Docs>
1073         <param name="option">
1074           The <see cref="T:Mono.Options.Option" /> to register.
1075         </param>
1076         <summary>
1077           Registers <paramref name="option" /> so that any options matching
1078           <see cref="M:Mono.Options.Option.GetNames" /> will be treated
1079           specially by 
1080           <see cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />.
1081         </summary>
1082         <returns>
1083           The current <see cref="T:Mono.Options.OptionSet" /> instance.
1084           This is to permit method chaining.
1085         </returns>
1086         <remarks>
1087           Registers each option name returned by 
1088           <see cref="M:Mono.Options.Option.GetNames" />, ensuring that any
1089           option with a matching name will be handled by the 
1090           <paramref name="option" /> instance.
1091         </remarks>
1092         <exception cref="T:System.ArgumentException">
1093           <paramref name="option" /> has an alias (as returned from
1094           <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
1095           a previously registered <see cref="T:Mono.Options.Option" />.
1096         </exception>
1097         <exception cref="T:System.ArgumentNullException">
1098           <paramref name="option" /> is <see langword="null" />.
1099         </exception>
1100       </Docs>
1101     </Member>
1102     <Member MemberName="Add">
1103       <MemberSignature Language="C#" Value="public Mono.Options.OptionSet Add (string prototype, Mono.Options.OptionAction&lt;string,string&gt; action);" />
1104       <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.OptionSet Add(string prototype, class Mono.Options.OptionAction`2&lt;string, string&gt; action) cil managed" />
1105       <MemberType>Method</MemberType>
1106       <AssemblyInfo>
1107         <AssemblyVersion>0.2.0.0</AssemblyVersion>
1108         <AssemblyVersion>0.2.1.0</AssemblyVersion>
1109         <AssemblyVersion>0.2.2.0</AssemblyVersion>
1110       </AssemblyInfo>
1111       <ReturnValue>
1112         <ReturnType>Mono.Options.OptionSet</ReturnType>
1113       </ReturnValue>
1114       <Parameters>
1115         <Parameter Name="prototype" Type="System.String" />
1116         <Parameter Name="action" Type="Mono.Options.OptionAction&lt;System.String,System.String&gt;" />
1117       </Parameters>
1118       <Docs>
1119         <param name="prototype">
1120           A <see cref="T:System.String" /> containing all option aliases to
1121           register, an (optional) type specifier, and an (optional) value
1122           separator list; see 
1123           <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
1124           for details.
1125         </param>
1126         <param name="action">
1127           A <see cref="T:Mono.Options.OptionAction{System.String,System.String}" />
1128           to invoke when an option is parsed.
1129         </param>
1130         <summary>
1131           Registers each alias within <paramref name="prototype" /> so that any 
1132           options matching the aliases in <paramref name="prototype" /> will be
1133           handled by <paramref name="action" /> during any subsequent
1134           <see cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />
1135           calls.
1136         </summary>
1137         <returns>
1138           The current <see cref="T:Mono.Options.OptionSet" /> instance.
1139           This is to permit method chaining.
1140         </returns>
1141         <remarks>
1142           Calls 
1143           <see cref="M:Mono.Options.OptionSet.Add(System.String,System.String,Mono.Options.OptionAction{System.String,System.String})" />
1144           with a <paramref name="description" /> value of 
1145           <see langword="null" />.
1146         </remarks>
1147         <altmember cref="M:Mono.Options.OptionSet.Add(System.String,System.String,Mono.Options.OptionAction{System.String,System.String})" />
1148         <altmember cref="M:Mono.Options.OptionSet.Add(Mono.Options.Option)" />
1149         <exception cref="T:System.ArgumentException">
1150           <paramref name="prototype" /> has an alias (as returned from
1151           <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
1152           a previously registered <see cref="T:Mono.Options.Option" />.
1153         </exception>
1154         <exception cref="T:System.ArgumentNullException">
1155           <para>
1156             <paramref name="prototype" /> is <see langword="null" /></para>
1157           <para>-or-</para>
1158           <para>
1159             <paramref name="action" /> is <see langword="null" /></para>
1160         </exception>
1161       </Docs>
1162     </Member>
1163     <Member MemberName="Add">
1164       <MemberSignature Language="C#" Value="public Mono.Options.OptionSet Add (string prototype, Action&lt;string&gt; action);" />
1165       <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.OptionSet Add(string prototype, class System.Action`1&lt;string&gt; action) cil managed" />
1166       <MemberType>Method</MemberType>
1167       <AssemblyInfo>
1168         <AssemblyVersion>0.2.0.0</AssemblyVersion>
1169         <AssemblyVersion>0.2.1.0</AssemblyVersion>
1170         <AssemblyVersion>0.2.2.0</AssemblyVersion>
1171       </AssemblyInfo>
1172       <ReturnValue>
1173         <ReturnType>Mono.Options.OptionSet</ReturnType>
1174       </ReturnValue>
1175       <Parameters>
1176         <Parameter Name="prototype" Type="System.String" />
1177         <Parameter Name="action" Type="System.Action&lt;System.String&gt;" />
1178       </Parameters>
1179       <Docs>
1180         <param name="prototype">
1181           A <see cref="T:System.String" /> containing all option aliases to
1182           register, an (optional) type specifier, and an (optional) value
1183           separator list; see 
1184           <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
1185           for details.
1186         </param>
1187         <param name="action">
1188           A <see cref="T:System.Action{System.String}" />
1189           to invoke when an option is parsed.
1190         </param>
1191         <summary>
1192           Registers each alias within <paramref name="prototype" /> so that any 
1193           options matching the aliases in <paramref name="prototype" /> will be
1194           handled by <paramref name="action" /> during any subsequent
1195           <see cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />
1196           calls.
1197         </summary>
1198         <returns>
1199           The current <see cref="T:Mono.Options.OptionSet" /> instance.
1200           This is to permit method chaining.
1201         </returns>
1202         <remarks>
1203           Calls 
1204           <see cref="M:Mono.Options.OptionSet.Add(System.String,System.String,System.Action{System.String})" />
1205           with a <paramref name="description" /> value of 
1206           <see langword="null" />.
1207         </remarks>
1208         <altmember cref="M:Mono.Options.OptionSet.Add(System.String,System.String,System.Action{System.String})" />
1209         <altmember cref="M:Mono.Options.OptionSet.Add(Mono.Options.Option)" />
1210         <exception cref="T:System.ArgumentException">
1211           <paramref name="prototype" /> has an alias (as returned from
1212           <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
1213           a previously registered <see cref="T:Mono.Options.Option" />.
1214         </exception>
1215         <exception cref="T:System.ArgumentNullException">
1216           <para>
1217             <paramref name="prototype" /> is <see langword="null" /></para>
1218           <para>-or-</para>
1219           <para>
1220             <paramref name="action" /> is <see langword="null" /></para>
1221         </exception>
1222       </Docs>
1223     </Member>
1224     <Member MemberName="Add">
1225       <MemberSignature Language="C#" Value="public Mono.Options.OptionSet Add (string prototype, string description, Mono.Options.OptionAction&lt;string,string&gt; action);" />
1226       <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.OptionSet Add(string prototype, string description, class Mono.Options.OptionAction`2&lt;string, string&gt; action) cil managed" />
1227       <MemberType>Method</MemberType>
1228       <AssemblyInfo>
1229         <AssemblyVersion>0.2.0.0</AssemblyVersion>
1230         <AssemblyVersion>0.2.1.0</AssemblyVersion>
1231         <AssemblyVersion>0.2.2.0</AssemblyVersion>
1232       </AssemblyInfo>
1233       <ReturnValue>
1234         <ReturnType>Mono.Options.OptionSet</ReturnType>
1235       </ReturnValue>
1236       <Parameters>
1237         <Parameter Name="prototype" Type="System.String" />
1238         <Parameter Name="description" Type="System.String" />
1239         <Parameter Name="action" Type="Mono.Options.OptionAction&lt;System.String,System.String&gt;" />
1240       </Parameters>
1241       <Docs>
1242         <param name="prototype">
1243           A <see cref="T:System.String" /> containing all option aliases to
1244           register, an (optional) type specifier, and an (optional) value
1245           separator list; see 
1246           <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
1247           for details.
1248         </param>
1249         <param name="description">
1250           A <see cref="T:System.String" /> to be used to initialize
1251           the <see cref="P:Mono.Options.Option.Description" /> property.
1252         </param>
1253         <param name="action">
1254           A <see cref="T:Mono.Options.OptionAction{System.String,System.String}" />
1255           to invoke when an option is parsed.
1256         </param>
1257         <summary>
1258           Registers each alias within <paramref name="prototype" /> so that any 
1259           options matching the aliases in <paramref name="prototype" /> will be
1260           handled by <paramref name="action" /> during any subsequent
1261           <see cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />
1262           calls.
1263         </summary>
1264         <returns>
1265           The current <see cref="T:Mono.Options.OptionSet" /> instance.
1266           This is to permit method chaining.
1267         </returns>
1268         <remarks>
1269           <para>
1270             Use this method when <paramref name="prototype" /> should accept
1271             two values, generally a key and a value.
1272           </para>
1273           <block subset="none" type="note">
1274             If <paramref name="prototype" /> specifies a 
1275             <see cref="F:Mono.Options.OptionValueType.Optional" /> option,
1276             then it's possible that both the key and the value will be
1277             <see langword="null" /> in the callback function.
1278           </block>
1279         </remarks>
1280         <altmember cref="M:Mono.Options.OptionSet.Add(Mono.Options.Option)" />
1281         <exception cref="T:System.ArgumentException">
1282           <paramref name="prototype" /> has an alias (as returned from
1283           <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
1284           a previously registered <see cref="T:Mono.Options.Option" />.
1285         </exception>
1286         <exception cref="T:System.ArgumentNullException">
1287           <para>
1288             <paramref name="prototype" /> is <see langword="null" /></para>
1289           <para>-or-</para>
1290           <para>
1291             <paramref name="action" /> is <see langword="null" /></para>
1292         </exception>
1293       </Docs>
1294     </Member>
1295     <Member MemberName="Add">
1296       <MemberSignature Language="C#" Value="public Mono.Options.OptionSet Add (string prototype, string description, Action&lt;string&gt; action);" />
1297       <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.OptionSet Add(string prototype, string description, class System.Action`1&lt;string&gt; action) cil managed" />
1298       <MemberType>Method</MemberType>
1299       <AssemblyInfo>
1300         <AssemblyVersion>0.2.0.0</AssemblyVersion>
1301         <AssemblyVersion>0.2.1.0</AssemblyVersion>
1302         <AssemblyVersion>0.2.2.0</AssemblyVersion>
1303       </AssemblyInfo>
1304       <ReturnValue>
1305         <ReturnType>Mono.Options.OptionSet</ReturnType>
1306       </ReturnValue>
1307       <Parameters>
1308         <Parameter Name="prototype" Type="System.String" />
1309         <Parameter Name="description" Type="System.String" />
1310         <Parameter Name="action" Type="System.Action&lt;System.String&gt;" />
1311       </Parameters>
1312       <Docs>
1313         <param name="prototype">
1314           A <see cref="T:System.String" /> containing all option aliases to
1315           register, an (optional) type specifier, and an (optional) value
1316           separator list; see 
1317           <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
1318           for details.
1319         </param>
1320         <param name="description">
1321           A <see cref="T:System.String" /> containing to used to initialize
1322           the <see cref="P:Mono.Options.Option.Description" /> property.
1323         </param>
1324         <param name="action">
1325           A <see cref="T:System.Action{System.String}" />
1326           to invoke when an option is parsed.
1327         </param>
1328         <summary>
1329           Registers each alias within <paramref name="prototype" /> so that any 
1330           options matching the aliases in <paramref name="prototype" /> will be
1331           handled by <paramref name="action" /> during any subsequent
1332           <see cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />
1333           calls.
1334         </summary>
1335         <returns>
1336           The current <see cref="T:Mono.Options.OptionSet" /> instance.
1337           This is to permit method chaining.
1338         </returns>
1339         <remarks>
1340         </remarks>
1341         <altmember cref="M:Mono.Options.OptionSet.Add(Mono.Options.Option)" />
1342         <exception cref="T:System.ArgumentException">
1343           <paramref name="option" /> has an alias (as returned from
1344           <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
1345           a previously registered <see cref="T:Mono.Options.Option" />.
1346         </exception>
1347         <exception cref="T:System.ArgumentNullException">
1348           <para>
1349             <paramref name="prototype" /> is <see langword="null" /></para>
1350           <para>-or-</para>
1351           <para>
1352             <paramref name="action" /> is <see langword="null" /></para>
1353         </exception>
1354       </Docs>
1355     </Member>
1356     <Member MemberName="Add&lt;T&gt;">
1357       <MemberSignature Language="C#" Value="public Mono.Options.OptionSet Add&lt;T&gt; (string prototype, Action&lt;T&gt; action);" />
1358       <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.OptionSet Add&lt;T&gt;(string prototype, class System.Action`1&lt;!!T&gt; action) cil managed" />
1359       <MemberType>Method</MemberType>
1360       <AssemblyInfo>
1361         <AssemblyVersion>0.2.0.0</AssemblyVersion>
1362         <AssemblyVersion>0.2.1.0</AssemblyVersion>
1363         <AssemblyVersion>0.2.2.0</AssemblyVersion>
1364       </AssemblyInfo>
1365       <ReturnValue>
1366         <ReturnType>Mono.Options.OptionSet</ReturnType>
1367       </ReturnValue>
1368       <TypeParameters>
1369         <TypeParameter Name="T" />
1370       </TypeParameters>
1371       <Parameters>
1372         <Parameter Name="prototype" Type="System.String" />
1373         <Parameter Name="action" Type="System.Action&lt;T&gt;" />
1374       </Parameters>
1375       <Docs>
1376         <typeparam name="T">
1377           The type of the option to parse and provide to the 
1378           <paramref name="action" /> callback.
1379         </typeparam>
1380         <param name="prototype">
1381           A <see cref="T:System.String" /> containing all option aliases to
1382           register, an (optional) type specifier, and an (optional) value
1383           separator list; see 
1384           <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
1385           for details.
1386         </param>
1387         <param name="action">
1388           A <see cref="T:System.Action{``0}" />
1389           to invoke when an option is parsed.
1390         </param>
1391         <summary>
1392           Registers each alias within <paramref name="prototype" /> so that any 
1393           options matching the aliases in <paramref name="prototype" /> will be
1394           handled by <paramref name="action" /> during any subsequent
1395           <see cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />
1396           calls.
1397         </summary>
1398         <returns>
1399           The current <see cref="T:Mono.Options.OptionSet" /> instance.
1400           This is to permit method chaining.
1401         </returns>
1402         <remarks>
1403           Calls 
1404           <see cref="M:Mono.Options.OptionSet.Add``1(System.String,System.String,System.Action{``0})" />
1405           with a <paramref name="description" /> value of 
1406           <see langword="null" />.
1407         </remarks>
1408         <altmember cref="M:Mono.Options.OptionSet.Add(Mono.Options.Option)" />
1409         <altmember cref="M:Mono.Options.OptionSet.Add``1(System.String,System.String,System.Action{``0})" />
1410         <exception cref="T:System.ArgumentException">
1411           <paramref name="option" /> has an alias (as returned from
1412           <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
1413           a previously registered <see cref="T:Mono.Options.Option" />.
1414         </exception>
1415       </Docs>
1416     </Member>
1417     <Member MemberName="Add&lt;T&gt;">
1418       <MemberSignature Language="C#" Value="public Mono.Options.OptionSet Add&lt;T&gt; (string prototype, string description, Action&lt;T&gt; action);" />
1419       <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.OptionSet Add&lt;T&gt;(string prototype, string description, class System.Action`1&lt;!!T&gt; action) cil managed" />
1420       <MemberType>Method</MemberType>
1421       <AssemblyInfo>
1422         <AssemblyVersion>0.2.0.0</AssemblyVersion>
1423         <AssemblyVersion>0.2.1.0</AssemblyVersion>
1424         <AssemblyVersion>0.2.2.0</AssemblyVersion>
1425       </AssemblyInfo>
1426       <ReturnValue>
1427         <ReturnType>Mono.Options.OptionSet</ReturnType>
1428       </ReturnValue>
1429       <TypeParameters>
1430         <TypeParameter Name="T" />
1431       </TypeParameters>
1432       <Parameters>
1433         <Parameter Name="prototype" Type="System.String" />
1434         <Parameter Name="description" Type="System.String" />
1435         <Parameter Name="action" Type="System.Action&lt;T&gt;" />
1436       </Parameters>
1437       <Docs>
1438         <typeparam name="T">
1439           The type of the option to parse and provide to the 
1440           <paramref name="action" /> callback.
1441         </typeparam>
1442         <param name="prototype">
1443           A <see cref="T:System.String" /> containing all option aliases to
1444           register, an (optional) type specifier, and an (optional) value
1445           separator list; see 
1446           <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
1447           for details.
1448         </param>
1449         <param name="description">
1450           A <see cref="T:System.String" /> containing to used to initialize
1451           the <see cref="P:Mono.Options.Option.Description" /> property.
1452         </param>
1453         <param name="action">
1454           A <see cref="T:System.Action{``0}" />
1455           to invoke when an option is parsed.
1456         </param>
1457         <summary>
1458           Registers each alias within <paramref name="prototype" /> so that any 
1459           options matching the aliases in <paramref name="prototype" /> will be
1460           handled by <paramref name="action" /> during any subsequent
1461           <see cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />
1462           calls.
1463         </summary>
1464         <returns>
1465           The current <see cref="T:Mono.Options.OptionSet" /> instance.
1466           This is to permit method chaining.
1467         </returns>
1468         <remarks>
1469           <para>
1470             Use this typed overload when you want strongly typed option values
1471             that correspond to a managed type.
1472             <see cref="M:System.ComponentModel.TypeDescriptor.GetConverter(System.Type)" />
1473             is used to lookup the
1474             <see cref="T:System.ComponentModel.TypeConverter" /> to use when
1475             performing the string-to-type conversion.
1476           </para>
1477           <para>
1478             Special support is provided for <see cref="T:System.Nullable{X}" />
1479             types; <see cref="T:System.ComponentModel.TypeConverter" />
1480             doesn't currently support their use, but if 
1481             <typeparamref name="T" /> is a nullable type, then this method
1482             will instead use the 
1483             <see cref="T:System.ComponentModel.TypeConverter" /> for the 
1484             <typeparamref name="X" /> type.  This allows straightforward use
1485             of nullable types, identical to using any other strongly typed
1486             value.
1487           </para>
1488           <block subset="none" type="note">
1489             <para>
1490               If <paramref name="prototype" /> specifies an
1491               <see cref="F:Mono.Options.OptionValueType.Optional" /> value
1492               and the value is not provided, then <c>default(T)</c> is
1493               provided as the value to <paramref name="action" />.
1494             </para>
1495           </block>
1496         </remarks>
1497         <altmember cref="M:Mono.Options.OptionSet.Add(Mono.Options.Option)" />
1498         <exception cref="T:System.ArgumentException">
1499           <paramref name="option" /> has an alias (as returned from
1500           <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
1501           a previously registered <see cref="T:Mono.Options.Option" />.
1502         </exception>
1503         <exception cref="T:System.ArgumentNullException">
1504           <para>
1505             <paramref name="prototype" /> is <see langword="null" /></para>
1506           <para>-or-</para>
1507           <para>
1508             <paramref name="action" /> is <see langword="null" /></para>
1509         </exception>
1510       </Docs>
1511     </Member>
1512     <Member MemberName="Add&lt;TKey,TValue&gt;">
1513       <MemberSignature Language="C#" Value="public Mono.Options.OptionSet Add&lt;TKey,TValue&gt; (string prototype, Mono.Options.OptionAction&lt;TKey,TValue&gt; action);" />
1514       <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.OptionSet Add&lt;TKey, TValue&gt;(string prototype, class Mono.Options.OptionAction`2&lt;!!TKey, !!TValue&gt; action) cil managed" />
1515       <MemberType>Method</MemberType>
1516       <AssemblyInfo>
1517         <AssemblyVersion>0.2.0.0</AssemblyVersion>
1518         <AssemblyVersion>0.2.1.0</AssemblyVersion>
1519         <AssemblyVersion>0.2.2.0</AssemblyVersion>
1520       </AssemblyInfo>
1521       <ReturnValue>
1522         <ReturnType>Mono.Options.OptionSet</ReturnType>
1523       </ReturnValue>
1524       <TypeParameters>
1525         <TypeParameter Name="TKey" />
1526         <TypeParameter Name="TValue" />
1527       </TypeParameters>
1528       <Parameters>
1529         <Parameter Name="prototype" Type="System.String" />
1530         <Parameter Name="action" Type="Mono.Options.OptionAction&lt;TKey,TValue&gt;" />
1531       </Parameters>
1532       <Docs>
1533         <typeparam name="TKey">
1534           The type of the first argument to parse and provide to the 
1535           <paramref name="action" /> callback.
1536         </typeparam>
1537         <typeparam name="TValue">
1538           The type of the second argument to parse and provide to the 
1539           <paramref name="action" /> callback.
1540         </typeparam>
1541         <param name="prototype">
1542           A <see cref="T:System.String" /> containing all option aliases to
1543           register, an (optional) type specifier, and an (optional) value
1544           separator list; see 
1545           <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
1546           for details.
1547         </param>
1548         <param name="action">
1549           A <see cref="T:Mono.Options.OptionAction{TKey,TValue}" />
1550           to invoke when an option is parsed.
1551         </param>
1552         <summary>
1553           Registers each alias within <paramref name="prototype" /> so that any 
1554           options matching the aliases in <paramref name="prototype" /> will be
1555           handled by <paramref name="action" /> during any subsequent
1556           <see cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />
1557           calls.
1558         </summary>
1559         <returns>
1560           The current <see cref="T:Mono.Options.OptionSet" /> instance.
1561           This is to permit method chaining.
1562         </returns>
1563         <remarks>
1564           Calls 
1565           <see cref="M:Mono.Options.OptionSet.Add``2(System.String,System.String,Mono.Options.OptionAction{``0,``1})" />
1566           with a <paramref name="description" /> value of 
1567           <see langword="null" />.
1568         </remarks>
1569         <altmember cref="M:Mono.Options.OptionSet.Add(Mono.Options.Option)" />
1570         <altmember cref="M:Mono.Options.OptionSet.Add``2(System.String,System.String,Mono.Options.OptionAction{``0,``1})" />
1571         <exception cref="T:System.ArgumentException">
1572           <paramref name="prototype" /> has an alias (as returned from
1573           <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
1574           a previously registered <see cref="T:Mono.Options.Option" />.
1575         </exception>
1576         <exception cref="T:System.ArgumentNullException">
1577           <para>
1578             <paramref name="prototype" /> is <see langword="null" /></para>
1579           <para>-or-</para>
1580           <para>
1581             <paramref name="action" /> is <see langword="null" /></para>
1582         </exception>
1583       </Docs>
1584     </Member>
1585     <Member MemberName="Add&lt;TKey,TValue&gt;">
1586       <MemberSignature Language="C#" Value="public Mono.Options.OptionSet Add&lt;TKey,TValue&gt; (string prototype, string description, Mono.Options.OptionAction&lt;TKey,TValue&gt; action);" />
1587       <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Mono.Options.OptionSet Add&lt;TKey, TValue&gt;(string prototype, string description, class Mono.Options.OptionAction`2&lt;!!TKey, !!TValue&gt; action) cil managed" />
1588       <MemberType>Method</MemberType>
1589       <AssemblyInfo>
1590         <AssemblyVersion>0.2.0.0</AssemblyVersion>
1591         <AssemblyVersion>0.2.1.0</AssemblyVersion>
1592         <AssemblyVersion>0.2.2.0</AssemblyVersion>
1593       </AssemblyInfo>
1594       <ReturnValue>
1595         <ReturnType>Mono.Options.OptionSet</ReturnType>
1596       </ReturnValue>
1597       <TypeParameters>
1598         <TypeParameter Name="TKey" />
1599         <TypeParameter Name="TValue" />
1600       </TypeParameters>
1601       <Parameters>
1602         <Parameter Name="prototype" Type="System.String" />
1603         <Parameter Name="description" Type="System.String" />
1604         <Parameter Name="action" Type="Mono.Options.OptionAction&lt;TKey,TValue&gt;" />
1605       </Parameters>
1606       <Docs>
1607         <typeparam name="TKey">
1608           The type of the first argument to parse and provide to the 
1609           <paramref name="action" /> callback.
1610         </typeparam>
1611         <typeparam name="TValue">
1612           The type of the second argument to parse and provide to the 
1613           <paramref name="action" /> callback.
1614         </typeparam>
1615         <param name="prototype">
1616           A <see cref="T:System.String" /> containing all option aliases to
1617           register, an (optional) type specifier, and an (optional) value
1618           separator list; see 
1619           <see cref="C:Mono.Options.Option(System.String,System.String,System.Int32)" />
1620           for details.
1621         </param>
1622         <param name="description">
1623           A <see cref="T:System.String" /> to be used to initialize
1624           the <see cref="P:Mono.Options.Option.Description" /> property.
1625         </param>
1626         <param name="action">
1627           A <see cref="T:Mono.Options.OptionAction{TKey,TValue}" />
1628           to invoke when an option is parsed.
1629         </param>
1630         <summary>
1631           Registers each alias within <paramref name="prototype" /> so that any 
1632           options matching the aliases in <paramref name="prototype" /> will be
1633           handled by <paramref name="action" /> during any subsequent
1634           <see cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />
1635           calls.
1636         </summary>
1637         <returns>
1638           The current <see cref="T:Mono.Options.OptionSet" /> instance.
1639           This is to permit method chaining.
1640         </returns>
1641         <remarks>
1642           <para>
1643             Use this method when <paramref name="prototype" /> should accept
1644             two typed values, generally a key and a value.
1645           </para>
1646           <block subset="none" type="note">
1647             <para>
1648               If <paramref name="prototype" /> specifies an
1649               <see cref="F:Mono.Options.OptionValueType.Optional" /> value
1650               and the value is not provided, then <c>default(TKey)</c> and
1651               <c>default(TValue)</c> may be provided as the values to
1652               <paramref name="action" />.
1653             </para>
1654           </block>
1655         </remarks>
1656         <altmember cref="M:Mono.Options.OptionSet.Add(Mono.Options.Option)" />
1657         <exception cref="T:System.ArgumentException">
1658           <paramref name="prototype" /> has an alias (as returned from
1659           <see cref="M:Mono.Options.Option.GetNames" />) that conflicts with
1660           a previously registered <see cref="T:Mono.Options.Option" />.
1661         </exception>
1662         <exception cref="T:System.ArgumentNullException">
1663           <para>
1664             <paramref name="prototype" /> is <see langword="null" /></para>
1665           <para>-or-</para>
1666           <para>
1667             <paramref name="action" /> is <see langword="null" /></para>
1668         </exception>
1669       </Docs>
1670     </Member>
1671     <Member MemberName="ArgumentSources">
1672       <MemberSignature Language="C#" Value="public System.Collections.ObjectModel.ReadOnlyCollection&lt;Mono.Options.ArgumentSource&gt; ArgumentSources { get; }" />
1673       <MemberSignature Language="ILAsm" Value=".property instance class System.Collections.ObjectModel.ReadOnlyCollection`1&lt;class Mono.Options.ArgumentSource&gt; ArgumentSources" />
1674       <MemberType>Property</MemberType>
1675       <AssemblyInfo>
1676         <AssemblyVersion>0.2.2.0</AssemblyVersion>
1677       </AssemblyInfo>
1678       <ReturnValue>
1679         <ReturnType>System.Collections.ObjectModel.ReadOnlyCollection&lt;Mono.Options.ArgumentSource&gt;</ReturnType>
1680       </ReturnValue>
1681       <Docs>
1682         <summary>
1683           A collection of all
1684           <see cref="T:Mono.Options.ArgumentSource" />s which will be consulted during 
1685           <see cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />
1686           processing.
1687         </summary>
1688         <value>
1689           A <see cref="T:System.Collections.ObjectModel.ReadOnlyCollection{Mono.Options.ArgumentSource}" />
1690           containing all <see cref="T:Mono.Options.ArgumentSource" />s which
1691           have been 
1692           <see cref="M:Mono.Options.OptionSet.Add(Mono.Options.ArgumentSource)" />ed.
1693         </value>
1694         <remarks>
1695         </remarks>
1696       </Docs>
1697     </Member>
1698     <Member MemberName="CreateOptionContext">
1699       <MemberSignature Language="C#" Value="protected virtual Mono.Options.OptionContext CreateOptionContext ();" />
1700       <MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance class Mono.Options.OptionContext CreateOptionContext() cil managed" />
1701       <MemberType>Method</MemberType>
1702       <AssemblyInfo>
1703         <AssemblyVersion>0.2.0.0</AssemblyVersion>
1704         <AssemblyVersion>0.2.1.0</AssemblyVersion>
1705         <AssemblyVersion>0.2.2.0</AssemblyVersion>
1706       </AssemblyInfo>
1707       <ReturnValue>
1708         <ReturnType>Mono.Options.OptionContext</ReturnType>
1709       </ReturnValue>
1710       <Parameters />
1711       <Docs>
1712         <summary>
1713           Creates an <see cref="T:Mono.Options.OptionContext" /> instance.
1714         </summary>
1715         <returns>
1716           A <see cref="T:Mono.Options.OptionContext" /> instance to be used
1717           when parsing all options during the current
1718           <see cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />
1719           call.
1720         </returns>
1721         <remarks>
1722           <block subset="none" type="overrides">
1723             <para>
1724               This method can be overridden if
1725               <see cref="M:Mono.Options.OptionSet.Parse(System.String,Mono.Options.OptionContext)" />
1726               is overridden and requires access to an 
1727               <see cref="T:Mono.Options.OptionContext" /> subclass to store
1728               additional information during the current 
1729               <see cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />
1730               invocation.
1731             </para>
1732           </block>
1733         </remarks>
1734         <altmember cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />
1735         <altmember cref="M:Mono.Options.OptionSet.Parse(System.String,Mono.Options.OptionContext)" />
1736       </Docs>
1737     </Member>
1738     <Member MemberName="GetKeyForItem">
1739       <MemberSignature Language="C#" Value="protected override string GetKeyForItem (Mono.Options.Option item);" />
1740       <MemberSignature Language="ILAsm" Value=".method familyhidebysig virtual instance string GetKeyForItem(class Mono.Options.Option item) cil managed" />
1741       <MemberType>Method</MemberType>
1742       <AssemblyInfo>
1743         <AssemblyVersion>0.2.1.0</AssemblyVersion>
1744         <AssemblyVersion>0.2.2.0</AssemblyVersion>
1745       </AssemblyInfo>
1746       <ReturnValue>
1747         <ReturnType>System.String</ReturnType>
1748       </ReturnValue>
1749       <Parameters>
1750         <Parameter Name="item" Type="Mono.Options.Option" />
1751       </Parameters>
1752       <Docs>
1753         <param name="item">
1754           An <see cref="T:Mono.Options.Option" /> to return the key of.
1755         </param>
1756         <summary>
1757           Returns <c><paramref name="item" />.GetNames()[0]</c>.
1758         </summary>
1759         <returns>
1760           A <see cref="T:System.String" /> containing the first alias returned
1761           by <see cref="M:Mono.Options.Option.GetNames" />.
1762         </returns>
1763         <remarks>
1764           <para>
1765             This is to support the 
1766             <see cref="T:System.Collections.ObjectModel.KeyedCollection{System.String,Mono.Options.Option}" />
1767             infrastructure.  
1768             <see cref="T:System.Collections.ObjectModel.KeyedCollection{System.String,Mono.Options.Option}" />
1769             assumes only one key per item, so we arbitrarily choose the first
1770             item in the option alias list.
1771           </para>
1772           <block subset="none" type="note">
1773             All aliases returned by 
1774             <see cref="M:Mono.Options.Option.GetNames" /> are still
1775             registered with 
1776             <see cref="T:System.Collections.ObjectModel.KeyedCollection{System.String,Mono.Options.Option}" />
1777             even though 
1778             <see cref="M:Mono.Options.OptionSet.GetKeyForItem(Mono.Options.Option)" />
1779             will never return them.  Consequently, 
1780             <see cref="M:System.Collections.ObjectModel.KeyedCollection{System.String,Mono.Options.Option}.Contains(`0)" />
1781             and
1782             <see cref="P:System.Collections.ObjectModel.KeyedCollection{System.String,Mono.Options.Option}.Item(`0)" />
1783             will both correctly use all aliases returned by 
1784             <see cref="M:Mono.Options.Option.GetNames" />.
1785           </block>
1786         </remarks>
1787       </Docs>
1788     </Member>
1789     <Member MemberName="GetOptionForName">
1790       <MemberSignature Language="C#" Value="protected Mono.Options.Option GetOptionForName (string option);" />
1791       <MemberSignature Language="ILAsm" Value=".method familyhidebysig instance class Mono.Options.Option GetOptionForName(string option) cil managed" />
1792       <MemberType>Method</MemberType>
1793       <AssemblyInfo>
1794         <AssemblyVersion>0.2.0.0</AssemblyVersion>
1795         <AssemblyVersion>0.2.1.0</AssemblyVersion>
1796         <AssemblyVersion>0.2.2.0</AssemblyVersion>
1797       </AssemblyInfo>
1798       <Attributes>
1799         <Attribute>
1800           <AttributeName>System.Obsolete("Use KeyedCollection.this[string]")</AttributeName>
1801         </Attribute>
1802       </Attributes>
1803       <ReturnValue>
1804         <ReturnType>Mono.Options.Option</ReturnType>
1805       </ReturnValue>
1806       <Parameters>
1807         <Parameter Name="option" Type="System.String" />
1808       </Parameters>
1809       <Docs>
1810         <param name="option">
1811           A <see cref="T:System.String" /> containing the option name to
1812           lookup.
1813         </param>
1814         <summary>
1815           Looks up the <see cref="T:Mono.Options.Option" /> registered to
1816           handle the option name <paramref name="option" />.
1817         </summary>
1818         <returns>
1819           The <see cref="T:Mono.Options.Option" /> instance registered to
1820           handle the option name <paramref name="option" />.
1821           If there is no registered handler for <paramref name="option" />,
1822           then <see langword="null" /> is returned.
1823         </returns>
1824         <remarks>
1825           <para>
1826             Subclasses can use this function to perform 
1827             <paramref name="option" /> lookup when overriding
1828             <see cref="M:Mono.Options.OptionSet.Parse(System.String,Mono.Options.OptionContext)" />.
1829           </para>
1830         </remarks>
1831         <altmember cref="M:Mono.Options.OptionSet.Parse(System.String,Mono.Options.OptionContext)" />
1832         <exception cref="T:System.ArgumentNullException">
1833           <paramref name="option" /> is <see langword="null" />.
1834         </exception>
1835       </Docs>
1836     </Member>
1837     <Member MemberName="GetOptionParts">
1838       <MemberSignature Language="C#" Value="protected bool GetOptionParts (string argument, out string flag, out string name, out string sep, out string value);" />
1839       <MemberSignature Language="ILAsm" Value=".method familyhidebysig instance bool GetOptionParts(string argument, string flag, string name, string sep, string value) cil managed" />
1840       <MemberType>Method</MemberType>
1841       <AssemblyInfo>
1842         <AssemblyVersion>0.2.0.0</AssemblyVersion>
1843         <AssemblyVersion>0.2.1.0</AssemblyVersion>
1844         <AssemblyVersion>0.2.2.0</AssemblyVersion>
1845       </AssemblyInfo>
1846       <ReturnValue>
1847         <ReturnType>System.Boolean</ReturnType>
1848       </ReturnValue>
1849       <Parameters>
1850         <Parameter Name="argument" Type="System.String" />
1851         <Parameter Name="flag" Type="System.String&amp;" RefType="out" />
1852         <Parameter Name="name" Type="System.String&amp;" RefType="out" />
1853         <Parameter Name="sep" Type="System.String&amp;" RefType="out" />
1854         <Parameter Name="value" Type="System.String&amp;" RefType="out" />
1855       </Parameters>
1856       <Docs>
1857         <param name="argument">
1858           A <see cref="T:System.String" /> containing the option to parse into
1859           its constituent parts.
1860         </param>
1861         <param name="flag">
1862           A <see cref="T:System.String" /> reference which will be set to 
1863           <see langword="null" /> if the method returns 
1864           <see langword="false" />, or set to the flag the option starts with
1865           if the method returns <see langword="true" />.
1866           Valid flags include: <c>-</c>, <c>--</c>, and <c>/</c>.
1867         </param>
1868         <param name="name">
1869           A <see cref="T:System.String" /> reference which will be set to 
1870           <see langword="null" /> if the method returns 
1871           <see langword="false" />, or set to the option name following a
1872           valid flag if the method returns <see langword="true" />.
1873           No lookup is made to determine that flag has been registered via a 
1874           prior call to 
1875           <see cref="M:Mono.Options.OptionSet.Add(Mono.Options.Option)" />
1876           or related overload.
1877         </param>
1878         <param name="sep">
1879           A <see cref="T:System.String" /> reference which will be set to 
1880           <see langword="null" /> if either the method returns 
1881           <see langword="false" /> or if <c>=</c> or <c>:</c> was not found
1882           within <paramref name="argument" />; if the method returns 
1883           <see langword="true" /> and <paramref name="argument" /> contains a
1884           <c>=</c> or <c>:</c>, then <paramref name="sep" /> will contain
1885           either <c>=</c> or <c>:</c>, whichever was found within 
1886           <paramref name="argument" />.
1887         </param>
1888         <param name="value">
1889           A <see cref="T:System.String" /> reference which will be set to 
1890           <see langword="null" /> if either the method returns 
1891           <see langword="false" /> or if <paramref name="sep" /> is null;
1892           if the method returns <see langword="true" /> and 
1893           <paramref name="sep" /> is not <see langword="null" />, then
1894           <paramref name="value" /> will contain all text after 
1895           <paramref name="sep" />.
1896         </param>
1897         <summary>
1898           Splits <paramref name="argument" /> into its constituent parts.
1899         </summary>
1900         <returns>
1901           <see langword="true" /> if <paramref name="argument" /> could be split
1902           into its constituent parts, and <paramref name="flag" /> and 
1903           <paramref name="name" /> are set (<paramref name="sep" /> and
1904           <paramref name="value" /> may not be set, depending on whether or
1905           not they are present within <paramref name="argument" />);
1906           <see langword="true" /> if <paramref name="argument" /> is not the
1907           possible start of a valid option.
1908         </returns>
1909         <remarks>
1910           <para>
1911             Subclasses can call this method from their 
1912             <see cref="M:Mono.Options.OptionSet.Parse(System.String,Mono.Options.OptionContext)" />
1913             method to determine whether a given string is an option, and to
1914             split the option up for further processing.
1915           </para>
1916           <para>
1917             For example, <c>GetOptionParts("foo", ...)</c> would return 
1918             <see langword="false" />, while 
1919             <c>GetOptionParts("--foo=bar", ...)</c>
1920             would result in <paramref name="flag" /> containing <c>--</c>, 
1921             <paramref name="name" /> containing <c>foo</c>, 
1922             <paramref name="sep" /> containing <c>=</c>, and
1923             <paramref name="value" /> containing <c>bar</c>.
1924           </para>
1925         </remarks>
1926         <exception cref="T:System.ArgumentNullException">
1927           <paramref name="argument" /> is <see langword="null" />.
1928         </exception>
1929       </Docs>
1930     </Member>
1931     <Member MemberName="InsertItem">
1932       <MemberSignature Language="C#" Value="protected override void InsertItem (int index, Mono.Options.Option item);" />
1933       <MemberSignature Language="ILAsm" Value=".method familyhidebysig virtual instance void InsertItem(int32 index, class Mono.Options.Option item) cil managed" />
1934       <MemberType>Method</MemberType>
1935       <AssemblyInfo>
1936         <AssemblyVersion>0.2.0.0</AssemblyVersion>
1937         <AssemblyVersion>0.2.1.0</AssemblyVersion>
1938         <AssemblyVersion>0.2.2.0</AssemblyVersion>
1939       </AssemblyInfo>
1940       <ReturnValue>
1941         <ReturnType>System.Void</ReturnType>
1942       </ReturnValue>
1943       <Parameters>
1944         <Parameter Name="index" Type="System.Int32" />
1945         <Parameter Name="item" Type="Mono.Options.Option" />
1946       </Parameters>
1947       <Docs>
1948         <param name="index">
1949           A <see cref="T:System.Int32" /> specifying the index to insert 
1950           <paramref name="item" /> into.
1951         </param>
1952         <param name="item">
1953           The <see cref="T:Mono.Options.Option" /> to insert.
1954         </param>
1955         <summary>
1956           Inserts <paramref name="item" /> at the specified 
1957           <paramref name="index" />.
1958         </summary>
1959         <remarks>
1960         </remarks>
1961       </Docs>
1962     </Member>
1963     <Member MemberName="MessageLocalizer">
1964       <MemberSignature Language="C#" Value="public Converter&lt;string,string&gt; MessageLocalizer { get; }" />
1965       <MemberSignature Language="ILAsm" Value=".property instance class System.Converter`2&lt;string, string&gt; MessageLocalizer" />
1966       <MemberType>Property</MemberType>
1967       <AssemblyInfo>
1968         <AssemblyVersion>0.2.0.0</AssemblyVersion>
1969         <AssemblyVersion>0.2.1.0</AssemblyVersion>
1970         <AssemblyVersion>0.2.2.0</AssemblyVersion>
1971       </AssemblyInfo>
1972       <ReturnValue>
1973         <ReturnType>System.Converter&lt;System.String,System.String&gt;</ReturnType>
1974       </ReturnValue>
1975       <Docs>
1976         <summary>
1977           Permits access to the message localization facility.
1978         </summary>
1979         <value>
1980           A <see cref="T:System.Converter{System.String,System.String}" />
1981           that can be used to localize messages.
1982         </value>
1983         <remarks>
1984           <para>
1985             <see cref="T:Mono.Options.Option" /> subclasses can use this
1986             property 
1987             (via <see cref="P:Mono.Options.OptionContext.OptionSet" />) to
1988             perform message localization for their own exception messages.
1989           </para>
1990         </remarks>
1991         <altmember cref="C:Mono.Options.OptionSet(System.Converter{System.String,System.String})" />
1992       </Docs>
1993     </Member>
1994     <Member MemberName="Parse">
1995       <MemberSignature Language="C#" Value="public System.Collections.Generic.List&lt;string&gt; Parse (System.Collections.Generic.IEnumerable&lt;string&gt; arguments);" />
1996       <MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Collections.Generic.List`1&lt;string&gt; Parse(class System.Collections.Generic.IEnumerable`1&lt;string&gt; arguments) cil managed" />
1997       <MemberType>Method</MemberType>
1998       <AssemblyInfo>
1999         <AssemblyVersion>0.2.0.0</AssemblyVersion>
2000         <AssemblyVersion>0.2.1.0</AssemblyVersion>
2001         <AssemblyVersion>0.2.2.0</AssemblyVersion>
2002       </AssemblyInfo>
2003       <ReturnValue>
2004         <ReturnType>System.Collections.Generic.List&lt;System.String&gt;</ReturnType>
2005       </ReturnValue>
2006       <Parameters>
2007         <Parameter Name="arguments" Type="System.Collections.Generic.IEnumerable&lt;System.String&gt;" />
2008       </Parameters>
2009       <Docs>
2010         <param name="arguments">
2011           A <see cref="T:System.Collections.Generic.IEnumerable&lt;System.String&gt;" />
2012           containing all arguments to parse.
2013         </param>
2014         <summary>
2015           Parses each <see cref="T:System.String" /> within 
2016           <paramref name="arguments" />, invoking any registered
2017           <paramref name="actions" /> if a registered option is encountered.
2018         </summary>
2019         <returns>
2020           A <see cref="T:System.Collections.Generic.List{System.String}" />
2021           containing all unhandled arguments.
2022         </returns>
2023         <remarks>
2024           <para>
2025             <c>Parse</c> looks at each argument from <paramref name="arguments" /> in order, passing each argument to each
2026             <see cref="T:Mono.Options.ArgumentSource" /> within
2027             <see cref="P:Mono.Options.OptionSet.ArgumentSources" /> using
2028             <see cref="M:Mono.Options.ArgumentSource.GetArguments(System.Int32, System.Collections.Generic.IEnumerable{System.String}@)" />
2029             until a source returns <see langword="true" /> (and the
2030             replacement sequence is used) or no <c>ArgumentSource</c> supports
2031             the argument.  <c>Parse</c> then attempts to process argument as
2032             an option.
2033           </para>
2034           <para>
2035             An argument is unhandled if:
2036           </para>
2037           <list type="bullet">
2038             <item>
2039               <term>
2040               There is no default handler registered (the <c>&lt;&gt;</c>
2041               handler).  If there is a default handler registered, then the
2042               default handler is invoked for otherwise-unhandled arguments.
2043             </term>
2044             </item>
2045             <item>
2046               <term>
2047               The option starts with a flag such as <c>-</c>, <c>--</c>,
2048               <c>/</c>, and the option name following the flag is
2049               unregistered.
2050             </term>
2051             </item>
2052             <item>
2053               <term>
2054               Or, the option does not start with a flag, and there is no prior
2055               parsed option that accepts a value that would use the argument as
2056               its value.
2057             </term>
2058             </item>
2059           </list>
2060           <para>
2061             Furthermore, argument parsing (including default handler invocation)
2062             stops whenever the <c>--</c> option is
2063             encountered.  This is in accordance with GNU conventions, and
2064             is frequently used to permit users to provide option-like
2065             filenames, e.g. <c>ls -lF -- -l</c> to view the file <c>-l</c>
2066             instead of needing to use <c>ls -lF ./-l</c>.
2067           </para>
2068         </remarks>
2069         <exception cref="T:Mono.Options.OptionException">
2070           <para>
2071             A value was not found for an <see cref="T:Mono.Options.Option" />
2072             requiring a value.
2073           </para>
2074           <para>-or-</para>
2075           <para>
2076             An attempt was made to bundle together an option requiring a
2077             value.
2078           </para>
2079           <para>-or-</para>
2080           <para>
2081             An exception was generated when trying to convert the value to the
2082             type <typeparamref name="T" />, for options added with
2083             <see cref="M:Mono.Options.OptionSet.Add``1(System.String,System.String,System.Action{``0})" />
2084             and related methods.  The originating exception is provided via
2085             the <see cref="P:System.Exception.InnerException" /> property.
2086           </para>
2087         </exception>
2088         <example>
2089           <para>
2090             The following example demonstrates some simple usage of 
2091             <see cref="T:Mono.Options.OptionSet" />.
2092           </para>
2093           <code lang="C#" src="examples/greet.cs">using System;
2094 using System.Collections.Generic;
2095 using NDesk.Options;
2096
2097 class Test {
2098         static int verbosity;
2099
2100         public static void Main (string[] args)
2101         {
2102                 bool show_help = false;
2103                 List&lt;string&gt; names = new List&lt;string&gt; ();
2104                 int repeat = 1;
2105
2106                 var p = new OptionSet () {
2107                         { "n|name=", "the {NAME} of someone to greet.",
2108                           v =&gt; names.Add (v) },
2109                         { "r|repeat=", 
2110                                 "the number of {TIMES} to repeat the greeting.\n" + 
2111                                         "this must be an integer.",
2112                           (int v) =&gt; repeat = v },
2113                         { "v", "increase debug message verbosity",
2114                           v =&gt; { if (v != null) ++verbosity; } },
2115                         { "h|help",  "show this message and exit", 
2116                           v =&gt; show_help = v != null },
2117                 };
2118
2119                 List&lt;string&gt; extra;
2120                 try {
2121                         extra = p.Parse (args);
2122                 }
2123                 catch (OptionException e) {
2124                         Console.Write ("greet: ");
2125                         Console.WriteLine (e.Message);
2126                         Console.WriteLine ("Try `greet --help' for more information.");
2127                         return;
2128                 }
2129
2130                 if (show_help) {
2131                         ShowHelp (p);
2132                         return;
2133                 }
2134
2135                 string message;
2136                 if (extra.Count &gt; 0) {
2137                         message = string.Join (" ", extra.ToArray ());
2138                         Debug ("Using new message: {0}", message);
2139                 }
2140                 else {
2141                         message = "Hello {0}!";
2142                         Debug ("Using default message: {0}", message);
2143                 }
2144
2145                 foreach (string name in names) {
2146                         for (int i = 0; i &lt; repeat; ++i)
2147                                 Console.WriteLine (message, name);
2148                 }
2149         }
2150
2151         static void ShowHelp (OptionSet p)
2152         {
2153                 Console.WriteLine ("Usage: greet [OPTIONS]+ message");
2154                 Console.WriteLine ("Greet a list of individuals with an optional message.");
2155                 Console.WriteLine ("If no message is specified, a generic greeting is used.");
2156                 Console.WriteLine ();
2157                 Console.WriteLine ("Options:");
2158                 p.WriteOptionDescriptions (Console.Out);
2159         }
2160
2161         static void Debug (string format, params object[] args)
2162         {
2163                 if (verbosity &gt; 0) {
2164                         Console.Write ("# ");
2165                         Console.WriteLine (format, args);
2166                 }
2167         }
2168 }
2169
2170 </code>
2171         </example>
2172       </Docs>
2173     </Member>
2174     <Member MemberName="Parse">
2175       <MemberSignature Language="C#" Value="protected virtual bool Parse (string argument, Mono.Options.OptionContext c);" />
2176       <MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance bool Parse(string argument, class Mono.Options.OptionContext c) cil managed" />
2177       <MemberType>Method</MemberType>
2178       <AssemblyInfo>
2179         <AssemblyVersion>0.2.0.0</AssemblyVersion>
2180         <AssemblyVersion>0.2.1.0</AssemblyVersion>
2181         <AssemblyVersion>0.2.2.0</AssemblyVersion>
2182       </AssemblyInfo>
2183       <ReturnValue>
2184         <ReturnType>System.Boolean</ReturnType>
2185       </ReturnValue>
2186       <Parameters>
2187         <Parameter Name="argument" Type="System.String" />
2188         <Parameter Name="c" Type="Mono.Options.OptionContext" />
2189       </Parameters>
2190       <Docs>
2191         <param name="argument">
2192           A <see cref="T:System.String" /> containing the current option to
2193           parse.
2194         </param>
2195         <param name="c">
2196           A <see cref="T:Mono.Options.OptionContext" /> containing the
2197           current parser context.
2198         </param>
2199         <summary>
2200           Parses <paramref name="argument" /> and invokes
2201           <see cref="M:Mono.Options.Option.Invoke(Mono.Options.OptionContext)" /> 
2202           if appropriate.
2203         </summary>
2204         <returns>
2205           A <see cref="T:System.Boolean" /> specifying whether or not
2206           <paramref name="argument" /> was handled.
2207           If <see langword="false" />, then
2208           <see cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />
2209           will return <paramref name="argument" /> as an unhandled option.
2210         </returns>
2211         <remarks>
2212           <para>
2213             This method is called for each <see cref="T:System.String" />
2214             within the <see cref="T:System.Collections.Generic.IEnumerable{System.String}" />
2215             provided to 
2216             <see cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />,
2217             which thus gives this method a chance to parse a single option, or
2218             chain together multiple options to form a single option (as is
2219             necessary when an option and its value are separated, e.g. with
2220             <c>-option value</c>).
2221           </para>
2222           <block subset="none" type="behaviors">
2223             <para>
2224               The default implementation will check 
2225               <see cref="P:Mono.Options.OptionContext.Option" />, which is
2226               assumed to be a <see cref="T:Mono.Options.Option" /> in need of
2227               a value.  If 
2228               <see cref="P:Mono.Options.OptionContext.Option" /> is 
2229               non-<see langword="null" />, then <paramref name="argument" />
2230               is 
2231               <see cref="M:Mono.Options.OptionValueCollection.Add(System.String)" />ed
2232               to <see cref="P:Mono.Options.OptionContext.OptionValues" /> and
2233               <see cref="M:Mono.Options.Option.Invoke(Mono.Options.OptionContext)" />
2234               is invoked.
2235             </para>
2236             <para>
2237               Next, <see cref="M:Mono.Options.OptionSet.GetOptionParts(System.String,System.String@,System.String@,System.String@,System.String@)" />
2238               is invoked.  If <c>GetOptionParts</c> returns 
2239               <see langword="false" />, then <see langword="false" /> is
2240               returned from <c>Parse</c>.
2241             </para>
2242             <para>
2243               Finally, check to see if the <paramref name="name" /> returned
2244               from <c>GetOptionParts</c> is registered; if it is, handle it
2245               appropriately.  If it isn't, check to see if 
2246               <paramref name="name" /> is a bundled option or a boolean
2247               option.  If <paramref name="name" /> isn't any registered
2248               option, then <see langword="false" /> is returned.
2249               Otherwise, <see langword="true" /> is returned.
2250             </para>
2251           </block>
2252           <block subset="none" type="overrides">
2253             <para>
2254               Inheriting types can override this method if they want to
2255               customize the per-option parsing within the containing
2256               <see cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />
2257               invocation.
2258             </para>
2259             <para>
2260               Inheriting types should consider overriding 
2261               <see cref="M:Mono.Options.OptionSet.CreateOptionContext" />
2262               if they want to store extra information for use and retrieval
2263               during each <c>Parse</c> invocation.
2264             </para>
2265           </block>
2266         </remarks>
2267         <altmember cref="M:Mono.Options.OptionSet.CreateOptionContext" />
2268         <altmember cref="M:Mono.Options.OptionSet.Parse(System.Collections.Generic.IEnumerable{System.String})" />
2269       </Docs>
2270     </Member>
2271     <Member MemberName="RemoveItem">
2272       <MemberSignature Language="C#" Value="protected override void RemoveItem (int index);" />
2273       <MemberSignature Language="ILAsm" Value=".method familyhidebysig virtual instance void RemoveItem(int32 index) cil managed" />
2274       <MemberType>Method</MemberType>
2275       <AssemblyInfo>
2276         <AssemblyVersion>0.2.0.0</AssemblyVersion>
2277         <AssemblyVersion>0.2.1.0</AssemblyVersion>
2278         <AssemblyVersion>0.2.2.0</AssemblyVersion>
2279       </AssemblyInfo>
2280       <ReturnValue>
2281         <ReturnType>System.Void</ReturnType>
2282       </ReturnValue>
2283       <Parameters>
2284         <Parameter Name="index" Type="System.Int32" />
2285       </Parameters>
2286       <Docs>
2287         <param name="index">
2288           A <see cref="T:System.Int32" /> containing the index of the 
2289           <see cref="T:Mono.Options.Option" /> to remove.
2290         </param>
2291         <summary>
2292           Removes the <see cref="T:Mono.Options.Option" /> at the specified
2293           <paramref name="index" />.
2294         </summary>
2295         <remarks>
2296         </remarks>
2297       </Docs>
2298     </Member>
2299     <Member MemberName="SetItem">
2300       <MemberSignature Language="C#" Value="protected override void SetItem (int index, Mono.Options.Option item);" />
2301       <MemberSignature Language="ILAsm" Value=".method familyhidebysig virtual instance void SetItem(int32 index, class Mono.Options.Option item) cil managed" />
2302       <MemberType>Method</MemberType>
2303       <AssemblyInfo>
2304         <AssemblyVersion>0.2.0.0</AssemblyVersion>
2305         <AssemblyVersion>0.2.1.0</AssemblyVersion>
2306         <AssemblyVersion>0.2.2.0</AssemblyVersion>
2307       </AssemblyInfo>
2308       <ReturnValue>
2309         <ReturnType>System.Void</ReturnType>
2310       </ReturnValue>
2311       <Parameters>
2312         <Parameter Name="index" Type="System.Int32" />
2313         <Parameter Name="item" Type="Mono.Options.Option" />
2314       </Parameters>
2315       <Docs>
2316         <param name="index">
2317           A <see cref="T:System.Int32" /> containing the index of the 
2318           <see cref="T:Mono.Options.Option" /> to change.
2319         </param>
2320         <param name="item">
2321           The new <see cref="T:Mono.Options.Option" /> to set at
2322           <paramref name="index" />.
2323         </param>
2324         <summary>
2325           Removes the current <see cref="T:Mono.Options.Option" /> at 
2326           <paramref name="index" /> and sets <paramref name="item" /> 
2327           as the value for the <paramref name="index" /> value.
2328         </summary>
2329         <remarks>
2330         </remarks>
2331       </Docs>
2332     </Member>
2333     <Member MemberName="WriteOptionDescriptions">
2334       <MemberSignature Language="C#" Value="public void WriteOptionDescriptions (System.IO.TextWriter o);" />
2335       <MemberSignature Language="ILAsm" Value=".method public hidebysig instance void WriteOptionDescriptions(class System.IO.TextWriter o) cil managed" />
2336       <MemberType>Method</MemberType>
2337       <AssemblyInfo>
2338         <AssemblyVersion>0.2.0.0</AssemblyVersion>
2339         <AssemblyVersion>0.2.1.0</AssemblyVersion>
2340         <AssemblyVersion>0.2.2.0</AssemblyVersion>
2341       </AssemblyInfo>
2342       <ReturnValue>
2343         <ReturnType>System.Void</ReturnType>
2344       </ReturnValue>
2345       <Parameters>
2346         <Parameter Name="o" Type="System.IO.TextWriter" />
2347       </Parameters>
2348       <Docs>
2349         <param name="o">
2350           The <see cref="T:System.IO.TextWriter" /> to write option
2351           descriptions to.
2352         </param>
2353         <summary>
2354           Writes <see cref="T:Mono.Options.Option" /> documentation to 
2355           <paramref name="o" />.
2356         </summary>
2357         <remarks>
2358           <para>
2359             For each <see cref="T:Mono.Options.Option" /> previously added to
2360             the current instance, this method writes out a comma-separated
2361             list of all <see cref="M:Mono.Options.Option.GetNames" />
2362             followed by the <see cref="P:Mono.Options.Option.Description" />.
2363           </para>
2364           <para>
2365             The <see cref="P:Mono.Options.Option.Description" /> is
2366             automatically wrapped so that output will flow nicely across
2367             multiple lines.  Wrapping is preferred at explicit embedded 
2368             newline characters (<c>\n</c>) or spaces, but words will be split
2369             (by adding a <c>-</c>) if necessary.
2370           </para>
2371           <para>
2372             Options requiring a value have <c>=VALUE</c> appended to their
2373             last name, while options with an optional value have
2374             <c>[=VALUE]</c> appended to their last name.
2375             The <c>VALUE</c> string can be changed by using a format
2376             specifier-like string within the 
2377             <see cref="P:Mono.Options.Option.Description" />.
2378           </para>
2379           <para>
2380             For <see cref="T:Mono.Options.Option" />s accepting one value,
2381             the string <c>{VALUE}</c> or <c>{0:VALUE}</c> can be used to
2382             explicitly provide the value name.  For <c>Option</c>s accepting
2383             more than one value, the leading number is used to specify which
2384             value the string is for.
2385           </para>
2386           <para>
2387             Once all <see cref="T:Mono.Options.Option" />s have been written,
2388             all <see cref="T:Mono.Options.ArgumentSource" />s are printed out
2389             using <see cref="M:Mono.Options.ArgumentSource.GetNames" /> and
2390             <see cref="P:Mono.Options.ArgumentSource.Description" />.
2391           </para>
2392         </remarks>
2393         <example>
2394           <para>
2395             The following example initializes a
2396             <see cref="T:Mono.Options.OptionSet" /> instance to accept a
2397             variety of parameters and provides a description for each
2398             parameter:
2399           </para>
2400           <code lang="C#" src="examples/greet.cs">using System;
2401 using System.Collections.Generic;
2402 using NDesk.Options;
2403
2404 class Test {
2405         static int verbosity;
2406
2407         public static void Main (string[] args)
2408         {
2409                 bool show_help = false;
2410                 List&lt;string&gt; names = new List&lt;string&gt; ();
2411                 int repeat = 1;
2412
2413                 var p = new OptionSet () {
2414                         { "n|name=", "the {NAME} of someone to greet.",
2415                           v =&gt; names.Add (v) },
2416                         { "r|repeat=", 
2417                                 "the number of {TIMES} to repeat the greeting.\n" + 
2418                                         "this must be an integer.",
2419                           (int v) =&gt; repeat = v },
2420                         { "v", "increase debug message verbosity",
2421                           v =&gt; { if (v != null) ++verbosity; } },
2422                         { "h|help",  "show this message and exit", 
2423                           v =&gt; show_help = v != null },
2424                 };
2425
2426                 List&lt;string&gt; extra;
2427                 try {
2428                         extra = p.Parse (args);
2429                 }
2430                 catch (OptionException e) {
2431                         Console.Write ("greet: ");
2432                         Console.WriteLine (e.Message);
2433                         Console.WriteLine ("Try `greet --help' for more information.");
2434                         return;
2435                 }
2436
2437                 if (show_help) {
2438                         ShowHelp (p);
2439                         return;
2440                 }
2441
2442                 string message;
2443                 if (extra.Count &gt; 0) {
2444                         message = string.Join (" ", extra.ToArray ());
2445                         Debug ("Using new message: {0}", message);
2446                 }
2447                 else {
2448                         message = "Hello {0}!";
2449                         Debug ("Using default message: {0}", message);
2450                 }
2451
2452                 foreach (string name in names) {
2453                         for (int i = 0; i &lt; repeat; ++i)
2454                                 Console.WriteLine (message, name);
2455                 }
2456         }
2457
2458         static void ShowHelp (OptionSet p)
2459         {
2460                 Console.WriteLine ("Usage: greet [OPTIONS]+ message");
2461                 Console.WriteLine ("Greet a list of individuals with an optional message.");
2462                 Console.WriteLine ("If no message is specified, a generic greeting is used.");
2463                 Console.WriteLine ();
2464                 Console.WriteLine ("Options:");
2465                 p.WriteOptionDescriptions (Console.Out);
2466         }
2467
2468         static void Debug (string format, params object[] args)
2469         {
2470                 if (verbosity &gt; 0) {
2471                         Console.Write ("# ");
2472                         Console.WriteLine (format, args);
2473                 }
2474         }
2475 }
2476
2477 </code>
2478           <para>
2479             Notice that when the above program is invoked with the
2480             <c>--help</c> parameter, 
2481             <see cref="M:Mono.Options.OptionSet.WriteOptionDescriptions(System.IO.TextWriter)" />
2482             is used to generate the <see cref="T:Mono.Options.Option" />
2483             description, that the <c>--repeat</c> description spans
2484             multiple lines, and that format specifiers such as <c>{NAME}</c>
2485             are used to provide a description for the option value:
2486           </para>
2487           <code lang="sh" src="examples/greet.txt">$ mono greet.exe --help
2488 Usage: greet [OPTIONS]+ message
2489 Greet a list of individuals with an optional message.
2490 If no message is specified, a generic greeting is used.
2491
2492 Options:
2493   -n, --name=NAME            the NAME of someone to greet.
2494   -r, --repeat=TIMES         the number of TIMES to repeat the greeting.
2495                                this must be an integer.
2496   -v                         increase debug message verbosity
2497   -h, --help                 show this message and exit
2498
2499 $ mono greet.exe -v- -n A -name=B --name=C /name D -nE
2500 Hello A!
2501 Hello B!
2502 Hello C!
2503 Hello D!
2504 Hello E!
2505
2506 $ mono greet.exe -v -n E custom greeting for: {0}
2507 # Using new message: custom greeting for: {0}
2508 custom greeting for: E
2509
2510 $ mono greet.exe -r 3 -n A
2511 Hello A!
2512 Hello A!
2513 Hello A!
2514
2515 $ mono greet.exe -r not-an-int
2516 greet: Could not convert string `not-an-int' to type Int32 for option `-r'.
2517 Try `greet --help' for more information.
2518 </code>
2519         </example>
2520       </Docs>
2521     </Member>
2522   </Members>
2523 </Type>