public static int Main(string[] args) { bool help = false; bool version = false; var p = new OptionSet() { "USAGE", " " + ProgName + " [OPTIONS]", "", "VERSION:", " " + Version, "", "DESCRIPTION:", " Run the TypeCobol Template Transpiler.", { "v|version", "Show version", _ => version = true }, { "h|help", "Show help", _ => help = true }, { "i|input=", "{PATH} The Skeleton xml input file", (string v) => SkeletonXmlFile = v }, { "o|output=", "{PATH} The optional C# file generated", (string v) => SkeletonCSharpFile = v }, }; System.Collections.Generic.List <string> arguments; try { arguments = p.Parse(args); } catch (OptionException ex) { return(exit(1, ex.Message)); } if (help) { p.WriteOptionDescriptions(System.Console.Out); return(0); } if (version) { System.Console.WriteLine(string.Format(AppResource.VersionMessage, ProgName, Version)); return(0); } if (SkeletonXmlFile == null) {//No file especifier return(exit(-1, AppResource.MissingSkeletonInputFile)); } if (SkeletonCSharpFile == null) { SkeletonCSharpFile = "Skeleton.cs"; } //Determines the ouput class name string classname = ""; System.IO.FileInfo fi = new System.IO.FileInfo(SkeletonCSharpFile); int indexExt = fi.Name.LastIndexOf('.'); if (indexExt > 0) { classname = fi.Name.Substring(0, indexExt).Trim(); } if (classname.Length == 0) { classname = "Skeleton"; } //Now Generate the file. return(SkeletonsController.Transpile(SkeletonXmlFile, SkeletonCSharpFile, classname) ? 0 : -1); }
public void SkeletonsFileTranspilationTest0() { string currentDir = System.IO.Directory.GetCurrentDirectory(); string xmlFile = System.IO.Path.Combine(System.IO.Path.Combine(currentDir, "Xml"), "TestSkeletons.xml"); string xsdFile = System.IO.Path.Combine(System.IO.Path.Combine(currentDir, "Xml"), "Skeleton.xsd"); SkeletonSaxParser parser = new SkeletonSaxParser(xmlFile, xsdFile); try { parser.Parse(); bool bValidate = parser.ValidationErrorCount == 0 && parser.ValidationWarningCount == 0; Assert.IsTrue(bValidate, bValidate ? "" : parser.ValidationMessage.ToString()); SkeletonsController controller = new SkeletonsController(parser.Skeletons); string code = controller.TranspiledCode; controller.CreateNodesModel(); System.Diagnostics.Debug.Write(code); } catch (SaxParser.SaxParser.ParsingException e) { throw e; } }