1 using System;
 2 using System.IO;
 3 using System.Collections;
 4 using soulcm.scm2html;
 5 
 6 string Version()
 7 {
 8     return "4.0.0";
 9 }
10 
11 void PrintHelp()
12 {
13     Console.Out() << "SoulCM HTML grammar generator version " << Version() << endl();
14     Console.Out() << "Usage: scm2html [options] { SCM2HTMLFILE.xml }" << endl();
15     Console.Out() << "options:" << endl();
16     Console.Out() << "--help | -h:" << endl();
17     Console.Out() << "  Print help and exit." << endl();
18     Console.Out() << "--verbose | -v" << endl();
19     Console.Out() << "  Be verbose." << endl();
20 }
21 
22 int main(int argcconst char** argv)
23 {
24     try
25     {
26         bool verbose = false;
27         List<string> filePaths;
28         for (int i = 1; i < argc; ++i;)
29         {
30             string arg = argv[i];
31             if (arg.StartsWith("--"))
32             {
33                 if (arg == "--help")
34                 {
35                     PrintHelp();
36                     return 1;
37                 }
38                 else if (arg == "--verbose")
39                 {
40                     verbose = true;
41                 }
42                 else
43                 {
44                     throw Exception("unknown option \'" + arg + "\'");
45                 }
46             }
47             else if (arg.StartsWith("-"))
48             {
49                 string options = arg.Substring(1);
50                 for (char o : options)
51                 {
52                     switch (o)
53                     {
54                         case 'h': PrintHelp();
55                         return 1;
56                         case 'v': verbose = true;
57                         break;
58                         default:
59                         {
60                             throw Exception("unknown option \'-" + string(o) + "\'");
61                             break;
62                         }
63                     }
64                 }
65             }
66             else
67             {
68                 filePaths.Add(GetFullPath(arg));
69             }
70         }
71         for (const string& scm2htmlFilePath : filePaths)
72         {
73             Scm2htmlXml xml(scm2htmlFilePath);
74             xml.Process(verbose);
75         }
76         if (verbose)
77         {
78             Console.WriteLine("done.");
79         }
80     }
81     catch (const Exception& ex)
82     {
83         Console.Error() << ex.Message() << endl();
84         return 1;
85     }
86     return 0;
87 }