* Makefile: Don't build make-map.exe.
[mono.git] / mcs / class / Mono.GetOptions / GetOptTest / GetOptTester.cs
1 using System;
2 using System.Collections;
3 using Mono.GetOptions;
4
5 namespace GetOptTest
6 {
7         class GetOptTestOptions : Options
8         {
9                 [Option(3, "Just a testing Parameter", 'p')]
10                 public string[] param = new string[] { "Default value" };
11
12                 [Option("Just a boolean testing parameter", 't')]
13                 public bool turnItOn = false;
14
15                 private bool verboseOn = false;
16
17                 [Option("Be verbose", 'v')]
18                 public bool verbose
19                 {
20                         set 
21                         { 
22                                 verboseOn = value; 
23                                 Console.WriteLine("verbose was set to : " + verboseOn);
24                         }
25                 }
26
27                 [Option(-1, "Execute a test routine", 's', null)]
28                 public WhatToDoNext simpleProcedure(int dids)
29                 {
30                         Console.WriteLine("Inside simpleProcedure({0})", dids);
31                         return WhatToDoNext.GoAhead;
32                 }
33
34                 [Option("Show usage syntax", 'u', "usage")]
35                 public override WhatToDoNext DoUsage()
36                 {
37                         base.DoUsage();
38                         return WhatToDoNext.GoAhead; 
39                 }
40
41                 public override WhatToDoNext DoHelp() // uses parent's OptionAttribute as is
42                 {
43                         base.DoHelp();
44                         return WhatToDoNext.GoAhead; 
45                 }
46
47                 public GetOptTestOptions()
48                 {
49                         this.ParsingMode = OptionsParsingMode.Both;
50                 }
51         }
52
53         /// <summary>
54         /// Summary description for GetOptTester.
55         /// </summary>
56         class GetOptTester 
57         {
58
59                 /// <summary>
60                 /// The main entry point for the application.
61                 /// </summary>
62                 [STAThread]
63                 static void Main(string[] args)
64                 {
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)
75                         {
76                                 Console.WriteLine("Parameters supplied for 'param' were:");
77                                 foreach (string Parameter in options.param)
78                                         Console.WriteLine("\t" + Parameter);
79                         }
80                         for(int i = 0; i < options.RemainingArguments.Length; i++)
81                                 Console.WriteLine("remaining args[{0}] = \"{1}\"",i,options.RemainingArguments[i]);
82                         Console.WriteLine("----------------------------------------");
83                 }
84         }
85 }