I've replaced the custom (broken) command line option parsing system
with Mono.Options.
At least I can now use unix-style absolute paths with DbMetal. <g>
Here is a summary of the patch and the relevant changes to Parameters.cs
while the full patch is attached.
---
src/DbMetal/AbstractParameters.cs | 695 -------------
src/DbMetal/DbMetal.csproj | 2 +-
src/DbMetal/Generator/Implementation/Processor.cs | 23 +-
src/DbMetal/Mono/Options.cs | 1112 +++++++++++++++++++++
src/DbMetal/Parameters.cs | 199 +++-
src/DbMetal/SqlMetal.csproj | 2 +-
6 files changed, 1281 insertions(+), 752 deletions(-)
delete mode 100644 src/DbMetal/AbstractParameters.cs
create mode 100644 src/DbMetal/Mono/Options.cs
diff --git a/src/DbMetal/Parameters.cs b/src/DbMetal/Parameters.cs
index a17514d..4340f0f 100644
--- a/src/DbMetal/Parameters.cs
+++ b/src/DbMetal/Parameters.cs
@@ -28,38 +28,39 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
+using System.IO;
+using System.Reflection;
+using DbLinq.Util;
+
+using Mono.Options;
namespace DbMetal
{
[DebuggerDisplay("Parameters from {Provider}, server={Server}")]
- public class Parameters : AbstractParameters
+ public class Parameters
{
/// <summary>
/// user name for database access
/// SQLMetal compatible
/// </summary>
- [Option("Login user ID.", ValueName = "name", Group = 1)]
public string User { get; set; }
/// <summary>
/// user password for database access
/// SQLMetal compatible
/// </summary>
- [Option("Login password.", ValueName = "password", Group = 1)]
public string Password { get; set; }
/// <summary>
/// server host name
/// SQLMetal compatible
/// </summary>
- [Option("Database server name.", ValueName = "name", Group = 1)]
public string Server { get; set; }
/// <summary>
/// database name
/// SQLMetal compatible
/// </summary>
- [Option("Database catalog on server.", ValueName = "name", Group = 1)]
public string Database { get; set; }
/// <summary>
@@ -67,60 +68,49 @@ namespace DbMetal
/// Database is always used to generate the specific DataContext name
/// SQLMetal compatible
/// </summary>
- [Option("Database connection string. Cannot be used with /server, /user or /password options.",
- ValueName = "connection string", Group = 1)]
public string Conn { get; set; }
/// <summary>
/// the namespace to put our classes into
/// SQLMetal compatible
/// </summary>
- [Option("Namespace of generated code (default: no namespace).", ValueName = "name", Group = 4)]
public string Namespace { get; set; }
/// <summary>
/// the language to generate classes for
/// SQLMetal compatible
/// </summary>
- [Option("Language for source code: C#, C#2 or VB (default: derived from extension on code file name).", ValueName = "name", Group = 4)]
public string Language { get; set; }
/// <summary>
/// If present, write out C# code
/// SQLMetal compatible
/// </summary>
- [Option("Output as source code. Cannot be used with /dbml option.", ValueName = "file", Group = 3)]
public string Code { get; set; }
/// <summary>
/// If present, write out DBML XML representing the DB
/// SQLMetal compatible
/// </summary>
- [Option("Output as dbml. Cannot be used with /map option.", ValueName = "file", Group = 3)]
public string Dbml { get; set; }
/// <summary>
/// when true, we will call Singularize()/Pluralize() functions.
/// SQLMetal compatible
/// </summary>
- [Option("Automatically pluralize or singularize class and member names using specified culture rules.", Group = 4)]
public bool Pluralize { get; set; }
- [Option("Specify culture for word recognition and pluralization (default=\"en\").", Group = 4)]
public string Culture { get; set; }
/// <summary>
/// Load object renamings from an xml file
/// DbLinq specific
/// </summary>
- [Option("Use mapping file.", ValueName = "file", Group = 3)]
- [Alternate("renamesFile")]
public string Aliases { get; set; }
/// <summary>
/// this is the "input file" parameter
/// </summary>
- [File("input file", "DBML input file.")]
public string SchemaXmlFile
{
get
@@ -129,38 +119,29 @@ namespace DbMetal
}
}
- [Option("Generate schema in code files (default='true').", Group = 4)]
public bool Schema { get; set; }
/// <summary>
/// base class from which all generated entities will inherit
/// SQLMetal compatible
/// </summary>
- [Option("Base class of entity classes in the generated code (default: entities have no base class).",
- ValueName = "type", Group = 4)]
public string EntityBase { get; set; }
/// <summary>
/// Interfaces to be implemented
/// </summary>
- [Option("Comma separated base interfaces of entity classes in the generated code (default: entities implement INotifyPropertyChanged).",
- ValueName = "interface(s)", Group = 4)]
public string EntityInterfaces { get; set; }
public string[] EntityImplementedInterfaces { get { return GetArray(EntityInterfaces); } }
/// <summary>
/// Extra attributes to be implemented by class
/// </summary>
- [Option("Comma separated attributes of entity classes in the generated code.",
- ValueName = "attribute(s)", Group = 4)]
public string EntityAttributes { get; set; }
public string[] EntityExposedAttributes { get { return GetArray(EntityAttributes); } }
/// <summary>
/// Extra attributes to be implemented by class
/// </summary>
- [Option("Comma separated attributes of entity members in the generated code.",
- ValueName = "attribute(s)", Group = 4)]
public string MemberAttributes { get; set; }
public string[] MemberExposedAttributes { get { return GetArray(MemberAttributes); } }
@@ -168,29 +149,20 @@ namespace DbMetal
/// base class from which all generated entities will inherit
/// SQLMetal compatible
/// </summary>
- [Option("Generates overrides for Equals() and GetHashCode() methods.", Group = 4)]
public bool GenerateEqualsAndHash { get; set; }
/// <summary>
/// export stored procedures
/// SQLMetal compatible
/// </summary>
- [Option("Extract stored procedures.", Group = 2)]
public bool Sprocs { get; set; }
/// <summary>
/// preserve case of database names
/// DbLinq specific
/// </summary>
- [Option("Transform names as indicated (default: net; may be: leave, pascal, camel, net).", Group = 4)]
public string Case { get; set; }
- /// <summary>
- /// ??
- /// DbLinq specific
- /// </summary>
- public bool VerboseForeignKeys { get; set; }
-
bool useDomainTypes = true;
/// <summary>
@@ -211,35 +183,42 @@ namespace DbMetal
/// picrap comment: you may use the tool to write output to Visual Studio output window instead of a console window
/// DbLinq specific
/// </summary>
- [Option("Wait for a key to be pressed after processing.", Group = 4)]
public bool ReadLineAtExit { get; set; }
/// <summary>
/// specifies a provider (which here is a pair or ISchemaLoader and IDbConnection implementors)
/// SQLMetal compatible
/// </summary>
- [Option("Specify provider. May be Ingres, MySql, Oracle, OracleODP, PostgreSql or Sqlite.",
- ValueName = "provider", Group = 1)]
public string Provider { get; set; }
/// <summary>
/// For fine tuning, we allow to specifiy an ISchemaLoader
/// DbLinq specific
/// </summary>
- [Option("Specify a custom ISchemaLoader implementation type.", ValueName = "type", Group = 1)]
public string DbLinqSchemaLoaderProvider { get; set; }
/// <summary>
/// For fine tuning, we allow to specifiy an IDbConnection
/// DbLinq specific
/// </summary>
- [Option("Specify a custom IDbConnection implementation type.", ValueName = "type", Group = 1)]
public string DatabaseConnectionProvider { get; set; }
- [Alternate("generate-timestamps")]
- [Option("Generate timestampes within the /code:<file> file. True by default.")]
public bool GenerateTimestamps { get; set; }
+ public bool Help { get; set; }
+
+ public IList<string> Extra = new List<string>();
+
+ TextWriter log;
+ public TextWriter Log
+ {
+ get { return log ?? Console.Out; }
+ set { log = value; }
+ }
+
+
+ protected OptionSet Options;
+
public Parameters()
{
Schema = true;
@@ -248,14 +227,83 @@ namespace DbMetal
EntityInterfaces = "INotifyPropertyChanged";//INotifyPropertyChanging INotifyPropertyChanged IModified
}
- public IEnumerable<Parameters> GetBatch(IList<string> args)
+ /// <summary>
+ /// Converts a list separated by a comma to a string array
+ /// </summary>
+ /// <param name="list"></param>
+
...
read more »
|
|
0001-Port-Db-Sql-Metal-to-Mono.Options.patch.gz
24K
Download
|