private static CommandLineProcessor InitializeCommandLine() { CommandLineProcessor clp = new CommandLineProcessor(); // DataSchema.exe Data.xml /scriptTarget:MSSQL /scriptOut:Data.sql /tableSchema:dbo /codeTarget:DotNet /codeOut:Data.dbml inputFilesParam = new CommandLineParameter ( true, "inputFiles", true, "Input file containing data schema" ); clp.CommandLineParameters.Add(inputFilesParam); scriptTargetParam = new CommandLineParameter ( "scriptTarget", false, CommandLineValueOption.One, "target", false, "Script target system, e.g. MSSQL" ); clp.CommandLineParameters.Add(scriptTargetParam); scriptOutParam = new CommandLineParameter ( "scriptOut", false, CommandLineValueOption.One, "filePath", false, "Output file containing script" ); clp.CommandLineParameters.Add(scriptOutParam); scriptDocParam = new CommandLineParameter ( "scriptDoc", false, CommandLineValueOption.Never, true, "Generate script documentiation statements" ); clp.CommandLineParameters.Add(scriptDocParam); tableSchemaNameParam = new CommandLineParameter ( "tableSchema", false, CommandLineValueOption.One, "name", false, "Name of database schema for tables, e.g. \"dbo\"" ); clp.CommandLineParameters.Add(tableSchemaNameParam); codeTargetParam = new CommandLineParameter ( "codeTarget", false, CommandLineValueOption.One, "target", false, "Code target system, e.g. DotNet" ); clp.CommandLineParameters.Add(codeTargetParam); codeOutParam = new CommandLineParameter ( "codeOut", false, CommandLineValueOption.One, "filePath", false, "Output file containing code" ); clp.CommandLineParameters.Add(codeOutParam); docOutParam = new CommandLineParameter ( "docOut", false, CommandLineValueOption.One, false, "Output file for documentation" ); clp.CommandLineParameters.Add(docOutParam); docCssFileParam = new CommandLineParameter ( "docCssFile", false, CommandLineValueOption.One, false, "An optional CSS file to embed in the output file for documentation" ); clp.CommandLineParameters.Add(docCssFileParam); nameParam = new CommandLineParameter ( "name", true, CommandLineValueOption.One, false, "The name of the database schema" ); clp.CommandLineParameters.Add(nameParam); clp.AutoCheckForMissingArguments = true; return clp; }
public string ParamShortName(CommandLineParameter param) { string result; if (param.Name == null) result = param.ValueName; else result = this.parameterMarker.ToString() + param.Name; return result; }
private string GetParamText(CommandLineParameter param) { StringBuilder sb = new StringBuilder(); if (param.Name == null) { sb.Append(param.ValueName); } else { sb.Append(this.parameterMarker); sb.Append(param.Name); string valueFriendlyName = string.IsNullOrEmpty(param.ValueName) ? "v" : param.ValueName; if (param.ValueOption == CommandLineValueOption.Optional) { sb.AppendFormat(valueMarker + "[<{0}>]", valueFriendlyName); } else if (param.ValueOption == CommandLineValueOption.One) { sb.AppendFormat(valueMarker + "<{0}>", valueFriendlyName); } } return sb.ToString().TrimEnd(); }
public CommandLineProcessorException(string message, CommandLineParameter param, Exception inner) : base(message, inner) { this.commandLineParameter = param; }
private Exception CreateValueMissingException(CommandLineParameter param) { return new CommandLineProcessorException("Value missing for parameter " + ParamShortName(param), param); }