From dae3cbb37e25556486aae49252d65220007140e2 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Thu, 4 Mar 2010 19:48:38 +0000 Subject: [PATCH] * Driver.cs, CommandLineOptions.cs: Remove Mono.GetOptions use and use Mono.Options instead (as Mono.GetOptions will be removed). * Makefile: Remove Mono.GetOptions.dll reference. * svcutil.exe.sources: Add Options.cs to the build. svn path=/trunk/mcs/; revision=153039 --- mcs/tools/svcutil/ChangeLog | 7 ++ mcs/tools/svcutil/CommandLineOptions.cs | 131 ++++++++++++++++++++---- mcs/tools/svcutil/Driver.cs | 12 ++- mcs/tools/svcutil/Makefile | 1 - mcs/tools/svcutil/svcutil.exe.sources | 1 + 5 files changed, 128 insertions(+), 24 deletions(-) diff --git a/mcs/tools/svcutil/ChangeLog b/mcs/tools/svcutil/ChangeLog index 7351c088915..2afdad080b5 100644 --- a/mcs/tools/svcutil/ChangeLog +++ b/mcs/tools/svcutil/ChangeLog @@ -1,3 +1,10 @@ +2010-01-28 Jonathan Pryor + + * Driver.cs, CommandLineOptions.cs: Remove Mono.GetOptions use and use + Mono.Options instead (as Mono.GetOptions will be removed). + * Makefile: Remove Mono.GetOptions.dll reference. + * svcutil.exe.sources: Add Options.cs to the build. + 2010-01-28 Atsushi Enomoto * Driver.cs, MoonlightChannelBaseExtension.cs, CommandLineOptions.cs: diff --git a/mcs/tools/svcutil/CommandLineOptions.cs b/mcs/tools/svcutil/CommandLineOptions.cs index ae37a14553c..f246c0f8b6f 100644 --- a/mcs/tools/svcutil/CommandLineOptions.cs +++ b/mcs/tools/svcutil/CommandLineOptions.cs @@ -1,17 +1,14 @@ using System; +using System.Collections.Generic; using System.Reflection; using System.Runtime.Serialization; -using Mono.GetOptions; + +using Mono.Options; [assembly: AssemblyTitle ("Mono service contract conversion tool")] [assembly: AssemblyDescription ("")] [assembly: AssemblyVersion ("0.1.0")] [assembly: AssemblyCopyright ("Copyright (C) 2006 Novell, Inc.")] -[assembly: Mono.UsageComplement("[metadataPath* | metadataUrl* | assemblyPath*]")] -[assembly: Mono.AdditionalInfo (@" -metadataPath : ws-mex file path. -metadataUrl: URL to ws-mex -assemblyPath: path to an assembly")] namespace Mono.ServiceContractTool { @@ -26,16 +23,118 @@ namespace Mono.ServiceContractTool XmlSerializer, } - public class CommandLineOptions : Options + public class CommandLineOptions { public CommandLineOptions () { + options = CreateOptions (); + } + + public bool Help, Usage, Version; + OptionSet options; + + public OptionSet CreateOptions () + { + return new OptionSet { + { "a|async", + "Generate async methods.", + v => GenerateAsync = v != null }, + { "config=", + "Configuration file names to generate.", + v => ConfigFiles.AddRange (v.Split (',')) }, + { "i|internal", + "Generate types as internal.", + v => GenerateTypesAsInternal = v != null }, + { "l|language=", + "Specify target code {LANGUAGE}. Default is 'csharp'.", + v => Language = v }, + { "monotouch", + "Generate MonoTouch client. (This option may vanish)", + v => GenerateMonoTouchProxy = v != null }, + { "moonlight", + "Generate moonlight client. (This option may vanish)", + v => GenerateMoonlightProxy = v != null }, + { "n|namespace=", + "Code namespace name to generate.", + v => Namespace = v }, + { "noConfig", + "Do not generate config file.", + v => NoConfig = v != null }, + { "noLogo", + "Do not show tool logo.", + v => NoLogo = v != null }, + { "o|out=", + "Output code filename.", + v => OutputFilename = v }, + { "r|reference=", + "Referenced assembly files.", + v => ReferencedAssemblies.AddRange (v.Split (',')) }, + { "tcv|targetClientVersion:", + "Indicate target client version. Valid values:\n" + + " Version35", + v => { + if (v == null) + return; + switch (v.ToLowerInvariant ()) { + case "version35": + TargetClientVersion35 = true; + break; + } + } }, + { "tm|typedMessage", + "Generate typed messages.", + v => GenerateTypedMessages = v != null }, + { "usage", + "Show usage syntax and exit.", + v => Usage = v != null }, + { "V|version", + "Display version and licensing information.", + v=> Version = v != null }, + { "h|?|help", + "Show this help list.", + v => Help = v != null }, + }; + } + + public void ProcessArgs (string[] args) + { + RemainingArguments = options.Parse (args); + } + + public void DoHelp () + { + ShowBanner (); + Console.WriteLine (); + DoUsage (); + Console.WriteLine ("Options:"); + options.WriteOptionDescriptions (Console.Out); + Console.WriteLine (); + Console.WriteLine ("metadataPath : ws-mex file path."); + Console.WriteLine ("metadataUrl: URL to ws-mex"); + Console.WriteLine ("assemblyPath: path to an assembly"); } + public void DoUsage () + { + Console.WriteLine ("Usage: svcutil [options] [metadataPath* | metadataUrl* | assemblyPath*]"); + } + + public void DoVersion () + { + ShowBanner (); + } + + public void ShowBanner () + { + Console.WriteLine ("Mono service contract conversion tool {0} - Copyright (C) 2006 Novell, Inc.", + Assembly.GetExecutingAssembly ().GetName ().Version); + } + + public List RemainingArguments; + //[Option ("Target directory to create files", 'd', "directory")] public string TargetDirectory; - [Option ("Output code filename", 'o', "out")] public string OutputFilename; //[Option ("Target output type", 't', "target")] @@ -44,8 +143,7 @@ namespace Mono.ServiceContractTool //[Option ("Validate all service endpoints", 'v', "validate")] public bool Validate; - [Option ("Configuration file names to generate", "config", MaxOccurs = -1)] - public string [] ConfigFiles; + public List ConfigFiles = new List (); // FIXME: support it public bool ChannelInterface; @@ -53,18 +151,14 @@ namespace Mono.ServiceContractTool // FIXME: support it public bool GenerateProxy; - [Option ("Generate async methods.", 'a', "async")] public bool GenerateAsync; - [Option ("Generate typed messages.", "typedMessage", "tm")] public bool GenerateTypedMessages; - [Option ("Indicate target client version is 3.5", "targetClientVersion:Version35", "tcv:Version35")] public bool TargetClientVersion35; bool generate_moonlight_proxy, generate_monotouch_proxy; - [Option ("Generate moonlight client. (This option may vanish.)", "moonlight")] public bool GenerateMoonlightProxy { get { return generate_moonlight_proxy; } set { @@ -75,7 +169,6 @@ namespace Mono.ServiceContractTool } } - [Option ("Generate MonoTouch client. (This option may vanish.)", "monotouch")] public bool GenerateMonoTouchProxy { // this is a hack. It does not differentiate from GenerateMoonlightProxy on getter. get { return generate_monotouch_proxy; } @@ -87,22 +180,16 @@ namespace Mono.ServiceContractTool } } - [Option ("Generate types as internal.", 'i', "internal")] public bool GenerateTypesAsInternal; - [Option ("Do not generate config file.", "noConfig")] public bool NoConfig; - [Option ("Specify target code language. 'csharp' By default.", 'l', "language")] public string Language = "csharp"; - [Option ("Code namespace name to generate.", 'n', "namespace")] public string Namespace = String.Empty; - [Option ("Referenced assembly files", 'r', "reference", MaxOccurs = -1)] - public string [] ReferencedAssemblies; + public List ReferencedAssemblies = new List (); - [Option ("Do not show tool logo", "noLogo")] public bool NoLogo; } } diff --git a/mcs/tools/svcutil/Driver.cs b/mcs/tools/svcutil/Driver.cs index ac352375d01..315d461d11e 100644 --- a/mcs/tools/svcutil/Driver.cs +++ b/mcs/tools/svcutil/Driver.cs @@ -35,7 +35,17 @@ namespace Mono.ServiceContractTool void Run (string [] args) { co.ProcessArgs (args); - if (co.RemainingArguments.Length == 0) { + if (co.Usage) { + co.DoUsage (); + return; + } + + if (co.Version) { + co.DoVersion (); + return; + } + + if (co.Help || co.RemainingArguments.Count == 0) { co.DoHelp (); return; } diff --git a/mcs/tools/svcutil/Makefile b/mcs/tools/svcutil/Makefile index b2efacb2709..7d99ab47bfa 100644 --- a/mcs/tools/svcutil/Makefile +++ b/mcs/tools/svcutil/Makefile @@ -3,7 +3,6 @@ SUBDIRS = include ../../build/rules.make LOCAL_MCS_FLAGS = \ - -r:Mono.GetOptions.dll \ -r:System.Runtime.Serialization.dll \ -r:System.ServiceModel.dll \ -r:System.Web.Services.dll diff --git a/mcs/tools/svcutil/svcutil.exe.sources b/mcs/tools/svcutil/svcutil.exe.sources index aa7b6bfd125..8e374e3447d 100644 --- a/mcs/tools/svcutil/svcutil.exe.sources +++ b/mcs/tools/svcutil/svcutil.exe.sources @@ -1,3 +1,4 @@ +../../class/Mono.Options/Mono.Options/Options.cs Driver.cs CommandLineOptions.cs MoonlightChannelBaseExtension.cs -- 2.25.1