MinitScript  0.9.31 PRE-BETA
minitscriptlibrary-main.cpp
Go to the documentation of this file.
1 #include <cstdlib>
2 #include <string>
3 #include <utility>
4 #include <vector>
5 
10 
11 using std::exit;
12 using std::pair;
13 using std::string;
14 using std::to_string;
15 using std::vector;
16 
20 
21 int main(int argc, char** argv)
22 {
23  Console::printLine(string("minitscriptlibrary ") + Version::getVersion());
24  Console::printLine(Version::getCopyright());
25  Console::printLine();
26 
27  auto nativeOnly = argc >= 2?string(argv[1]) == "--native-only":false;
28 
29  //
30  if ((argc - 2 - (nativeOnly == true?1:0)) / 2 == 0 || (argc - (nativeOnly == true?1:0)) % 2 == 1) {
31  Console::printLine("Usage: minitscriptlibrary [--native-only] script_filename1 script_class_name1 [script_filenameN script_class_nameN] library_filename");
32  exit(EXIT_FAILURE);
33  }
34 
35  //
36  auto libraryURI = string(argv[argc - 1]);
37  vector<pair<string, string>> scriptClassPairs;
38  for (auto i = 0; i < ((argc - 2 - (nativeOnly == true?1:0)) / 2); i++) {
39  auto scriptURI = string(argv[1 + (nativeOnly == true?1:0) + i * 2]);
40  auto className = string(argv[1 + (nativeOnly == true?1:0) + i * 2 + 1]);
41  scriptClassPairs.emplace_back(scriptURI, className);
42  }
43 
44  //
45  Generator::generateLibrary(scriptClassPairs, libraryURI, nativeOnly);
46 
47  //
48  return EXIT_SUCCESS;
49 }
MinitScript generator.
Definition: Generator.h:18
int main(int argc, char **argv)