2010-06-21 Atsushi Enomoto <atsushi@ximian.com>
[mcs.git] / tools / svcutil / CommandLineOptions.cs
blobf246c0f8b6f559b9f0de15c776516b8a0db97db6
1 using System;
2 using System.Collections.Generic;
3 using System.Reflection;
4 using System.Runtime.Serialization;
6 using Mono.Options;
8 [assembly: AssemblyTitle ("Mono service contract conversion tool")]
9 [assembly: AssemblyDescription ("")]
10 [assembly: AssemblyVersion ("0.1.0")]
11 [assembly: AssemblyCopyright ("Copyright (C) 2006 Novell, Inc.")]
13 namespace Mono.ServiceContractTool
15 public enum OutputType
17 None,
18 [EnumMember (Value = "code")]
19 Code,
20 [EnumMember (Value = "metadata")]
21 Metadata,
22 [EnumMember (Value = "xmlSerializer")]
23 XmlSerializer,
26 public class CommandLineOptions
28 public CommandLineOptions ()
30 options = CreateOptions ();
33 public bool Help, Usage, Version;
34 OptionSet options;
36 public OptionSet CreateOptions ()
38 return new OptionSet {
39 { "a|async",
40 "Generate async methods.",
41 v => GenerateAsync = v != null },
42 { "config=",
43 "Configuration file names to generate.",
44 v => ConfigFiles.AddRange (v.Split (',')) },
45 { "i|internal",
46 "Generate types as internal.",
47 v => GenerateTypesAsInternal = v != null },
48 { "l|language=",
49 "Specify target code {LANGUAGE}. Default is 'csharp'.",
50 v => Language = v },
51 { "monotouch",
52 "Generate MonoTouch client. (This option may vanish)",
53 v => GenerateMonoTouchProxy = v != null },
54 { "moonlight",
55 "Generate moonlight client. (This option may vanish)",
56 v => GenerateMoonlightProxy = v != null },
57 { "n|namespace=",
58 "Code namespace name to generate.",
59 v => Namespace = v },
60 { "noConfig",
61 "Do not generate config file.",
62 v => NoConfig = v != null },
63 { "noLogo",
64 "Do not show tool logo.",
65 v => NoLogo = v != null },
66 { "o|out=",
67 "Output code filename.",
68 v => OutputFilename = v },
69 { "r|reference=",
70 "Referenced assembly files.",
71 v => ReferencedAssemblies.AddRange (v.Split (',')) },
72 { "tcv|targetClientVersion:",
73 "Indicate target client version. Valid values:\n" +
74 " Version35",
75 v => {
76 if (v == null)
77 return;
78 switch (v.ToLowerInvariant ()) {
79 case "version35":
80 TargetClientVersion35 = true;
81 break;
83 } },
84 { "tm|typedMessage",
85 "Generate typed messages.",
86 v => GenerateTypedMessages = v != null },
87 { "usage",
88 "Show usage syntax and exit.",
89 v => Usage = v != null },
90 { "V|version",
91 "Display version and licensing information.",
92 v=> Version = v != null },
93 { "h|?|help",
94 "Show this help list.",
95 v => Help = v != null },
99 public void ProcessArgs (string[] args)
101 RemainingArguments = options.Parse (args);
104 public void DoHelp ()
106 ShowBanner ();
107 Console.WriteLine ();
108 DoUsage ();
109 Console.WriteLine ("Options:");
110 options.WriteOptionDescriptions (Console.Out);
111 Console.WriteLine ();
112 Console.WriteLine ("metadataPath : ws-mex file path.");
113 Console.WriteLine ("metadataUrl: URL to ws-mex");
114 Console.WriteLine ("assemblyPath: path to an assembly");
117 public void DoUsage ()
119 Console.WriteLine ("Usage: svcutil [options] [metadataPath* | metadataUrl* | assemblyPath*]");
122 public void DoVersion ()
124 ShowBanner ();
127 public void ShowBanner ()
129 Console.WriteLine ("Mono service contract conversion tool {0} - Copyright (C) 2006 Novell, Inc.",
130 Assembly.GetExecutingAssembly ().GetName ().Version);
133 public List<string> RemainingArguments;
135 //[Option ("Target directory to create files", 'd', "directory")]
136 public string TargetDirectory;
138 public string OutputFilename;
140 //[Option ("Target output type", 't', "target")]
141 public OutputType OutputType = OutputType.Code;
143 //[Option ("Validate all service endpoints", 'v', "validate")]
144 public bool Validate;
146 public List<string> ConfigFiles = new List<string> ();
148 // FIXME: support it
149 public bool ChannelInterface;
151 // FIXME: support it
152 public bool GenerateProxy;
154 public bool GenerateAsync;
156 public bool GenerateTypedMessages;
158 public bool TargetClientVersion35;
160 bool generate_moonlight_proxy, generate_monotouch_proxy;
162 public bool GenerateMoonlightProxy {
163 get { return generate_moonlight_proxy; }
164 set {
165 if (!value)
166 return;
167 generate_moonlight_proxy = true;
168 GenerateAsync = true;
172 public bool GenerateMonoTouchProxy {
173 // this is a hack. It does not differentiate from GenerateMoonlightProxy on getter.
174 get { return generate_monotouch_proxy; }
175 set {
176 if (!value)
177 return;
178 GenerateMoonlightProxy = true;
179 generate_monotouch_proxy = true;
183 public bool GenerateTypesAsInternal;
185 public bool NoConfig;
187 public string Language = "csharp";
189 public string Namespace = String.Empty;
191 public List<string> ReferencedAssemblies = new List<string> ();
193 public bool NoLogo;