1 #include <sng2html/sng2html/Project.hpp>
 2 #include <soulng/cppcode/InitDone.hpp>
 3 #include <soulng/util/InitDone.hpp>
 4 #include <sngxml/xpath/InitDone.hpp>
 5 #include <soulng/util/TextUtils.hpp>
 6 #include <iostream>
 7 #include <stdexcept>
 8 
 9 struct Initializer 
10 {
11     Initializer()
12     {
13         soulng::util::Init();
14         soulng::cppcode::Init();
15         sngxml::xpath::Init();
16     }
17     ~Initializer()
18     {
19         sngxml::xpath::Done();
20         soulng::cppcode::Done();
21         soulng::util::Done();
22     }
23 };
24 
25 using namespace soulng::util;
26 
27 int main(int argcconst char** argv)
28 {
29     Initializer initializer;
30     try
31     {
32         bool verbose = false;
33         std::vector<std::string> xmlFilePaths;
34         for (int i = 1; i < argc; ++i)
35         {
36             std::string arg = argv[i];
37             if (StartsWith(arg"--"))
38             {
39                 if (arg == "--verbose")
40                 {
41                     verbose = true;
42                 }
43                 else
44                 {
45                     throw std::runtime_error("unknown option '" + arg + "'");
46                 }
47             }
48             else if (StartsWith(arg"-"))
49             {
50                 std::string options = arg.substr(1);
51                 for (char o : options)
52                 {
53                     if (o == 'v')
54                     {
55                         verbose = true;
56                     }
57                     else
58                     {
59                         throw std::runtime_error("unknown option '-" + std::string(1o) + "'");
60                     }
61                 }
62             }
63             else
64             {
65                 xmlFilePaths.push_back(arg);
66             }
67         }
68         for (const std::string& xmlFilePath : xmlFilePaths)
69         {
70             sng2html::sng2html::Project project(verbosexmlFilePath);
71             project.Process();
72         }
73     }
74     catch (const std::exception&  ex;)
75     {
76         std::cerr << ex.what() << std::endl;
77         return 1;
78     }
79     return 0;
80 }