3 using System.Collections.Generic;
7 public static void Main (string[] args)
10 var macros = new Dictionary<string, string>();
11 bool create = false, extract = false, list = false;
12 string output = null, input = null;
15 var p = new OptionSet () {
16 "Usage: bundling [OPTIONS]+",
17 "Demo program to show the effects of bundling options and their values",
20 { "D:", "Predefine a macro with an (optional) value.",
23 throw new OptionException ("Missing macro name for option -D.",
27 { "d={-->}{=>}", "Alternate macro syntax.",
28 (m, v) => macros.Add (m, v) },
29 { "o=", "Specify the output file", v => output = v },
33 { "f=", "The input file", v => input = v },
34 { "x", "Extract the file", v => extract = v != null },
35 { "c", "Create the file", v => create = v != null },
36 { "t", "List the file", v => list = v != null },
39 "ls-like optional values:",
40 { "color:", "control whether and when color is used",
45 { "h|help", "show this message and exit",
46 v => show_help = v != null },
49 v => Console.WriteLine ("def handler: color={0}; arg={1}", color, v)},
55 catch (OptionException e) {
56 Console.Write ("bundling: ");
57 Console.WriteLine (e.Message);
58 Console.WriteLine ("Try `greet --help' for more information.");
63 p.WriteOptionDescriptions (Console.Out);
67 Console.WriteLine ("Macros:");
68 foreach (var m in (from k in macros.Keys orderby k select k)) {
69 Console.WriteLine ("\t{0}={1}", m, macros [m] ?? "<null>");
71 Console.WriteLine ("Options:");
72 Console.WriteLine ("\t Input File: {0}", input);
73 Console.WriteLine ("\tOuptut File: {0}", output);
74 Console.WriteLine ("\t Create: {0}", create);
75 Console.WriteLine ("\t Extract: {0}", extract);
76 Console.WriteLine ("\t List: {0}", list);
77 Console.WriteLine ("\t Color: {0}", color ?? "<null>");