コード例 #1
0
ファイル: Program.cs プロジェクト: helgihaf/Alpha
        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;
        }
コード例 #2
0
        public string ParamShortName(CommandLineParameter param)
        {
            string result;

            if (param.Name == null)
                result = param.ValueName;
            else
                result = this.parameterMarker.ToString() + param.Name;

            return result;
        }
コード例 #3
0
 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();
 }
コード例 #4
0
 public CommandLineProcessorException(string message, CommandLineParameter param, Exception inner)
     : base(message, inner)
 {
     this.commandLineParameter = param;
 }
コード例 #5
0
 private Exception CreateValueMissingException(CommandLineParameter param)
 {
     return new CommandLineProcessorException("Value missing for parameter " + ParamShortName(param), param);
 }