2 using System
.Collections
;
7 class GetOptTestOptions
: Options
9 [Option(3, "Just a testing Parameter", 'p')]
10 public string[] param
= new string[] { "Default value" }
;
12 [Option("Just a boolean testing parameter", 't')]
13 public bool turnItOn
= false;
15 private bool verboseOn
= false;
17 [Option("Be verbose", 'v')]
23 Console
.WriteLine("verbose was set to : " + verboseOn
);
27 [Option(-1, "Execute a test routine", 's', null)]
28 public WhatToDoNext
simpleProcedure(int dids
)
30 Console
.WriteLine("Inside simpleProcedure({0})", dids
);
31 return WhatToDoNext
.GoAhead
;
34 [Option("Show usage syntax", 'u', "usage")]
35 public override WhatToDoNext
DoUsage()
38 return WhatToDoNext
.GoAhead
;
41 public override WhatToDoNext
DoHelp() // uses parent´s OptionAttribute as is
44 return WhatToDoNext
.GoAhead
;
47 public GetOptTestOptions()
49 this.ParsingMode
= OptionsParsingMode
.Both
;
54 /// Summary description for GetOptTester.
60 /// The main entry point for the application.
63 static void Main(string[] args
)
65 Console
.WriteLine("------------ Original 'args'");
66 for(int i
= 0; i
< args
.Length
; i
++)
67 Console
.WriteLine("args[{0}] = \"{1}\"",i
,args
[i
]);
68 Console
.WriteLine("----------------------------------------");
69 Console
.WriteLine("------------ GetOptions Processing");
70 GetOptTestOptions options
= new GetOptTestOptions();
71 options
.ProcessArgs(args
);
72 Console
.WriteLine("----------------------------------------");
73 Console
.WriteLine("------------ Results");
74 if (options
.param
!= null)
76 Console
.WriteLine("Parameters supplied for 'param' were:");
77 foreach (string Parameter
in options
.param
)
78 Console
.WriteLine("\t" + Parameter
);
80 for(int i
= 0; i
< options
.RemainingArguments
.Length
; i
++)
81 Console
.WriteLine("remaining args[{0}] = \"{1}\"",i
,options
.RemainingArguments
[i
]);
82 Console
.WriteLine("----------------------------------------");