]> wagnertech.de Git - mDoc.git/blobdiff - csharp/mDoc/Program.cs
csharp-s6ts
[mDoc.git] / csharp / mDoc / Program.cs
diff --git a/csharp/mDoc/Program.cs b/csharp/mDoc/Program.cs
new file mode 100644 (file)
index 0000000..39110a2
--- /dev/null
@@ -0,0 +1,40 @@
+// See https://aka.ms/new-console-template for more information\r
+\r
+using System;\r
+using mDoc;\r
+\r
+class mDocMain{\r
+    static int command_dispatch(string[] args) {\r
+\r
+        // check runtime parameters\r
+        if (args.Length < 2) throw new ApplicationException("mdoc needs 2 arguments.");\r
+        \r
+        string file = args[0];\r
+        string template = args[1];\r
+        \r
+        Worker w = new Worker();\r
+        return w.convert(file, template);\r
+    }\r
+    public static int Main(string[] argv){\r
+        Console.WriteLine("mdoc");\r
+\r
+        string usage = "mdoc <source> <target-format>";\r
+\r
+        if (argv.Length < 1) {\r
+            Console.WriteLine(usage);\r
+            return 1;\r
+        }\r
+\r
+        try {\r
+            int ret = command_dispatch(argv);\r
+            if (ret != 0) {\r
+                Console.WriteLine(usage);\r
+            }\r
+            return ret;\r
+        }\r
+        catch (Exception e) {\r
+            Console.WriteLine(e.ToString());\r
+            throw new Exception(e.ToString());\r
+        }\r
+    }\r
+}\r