**** Merged from MCS ****
[mono-project.git] / mcs / class / Mono.GetOptions / GetOptTest / GetOptTester.cs
blob0ef35a602bdfa2ec52be1704506815d721e66583
1 using System;
2 using System.Collections;
3 using Mono.GetOptions;
5 namespace GetOptTest
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')]
18 public bool verbose
20 set
22 verboseOn = value;
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()
37 base.DoUsage();
38 return WhatToDoNext.GoAhead;
41 public override WhatToDoNext DoHelp() // uses parent´s OptionAttribute as is
43 base.DoHelp();
44 return WhatToDoNext.GoAhead;
47 public GetOptTestOptions()
49 this.ParsingMode = OptionsParsingMode.Both;
53 /// <summary>
54 /// Summary description for GetOptTester.
55 /// </summary>
56 class GetOptTester
59 /// <summary>
60 /// The main entry point for the application.
61 /// </summary>
62 [STAThread]
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("----------------------------------------");