| 58 | } |
| 59 | |
| 60 | int main(int argc, char *argv[]) |
| 61 | { |
| 62 | cerr << PACKAGE_NAME " " GITREV << endl; |
| 63 | |
| 64 | map<string,string> options; |
| 65 | regex optregex("--(help|log-to|verbose|target|sqlite|monetdb|version|dump-all-graphs|dump-all-queries|seed|dry-run|max-queries|rng-state|exclude-catalog)(?:=((?:.|\n)*))?"); |
| 66 | |
| 67 | for(char **opt = argv+1 ;opt < argv+argc; opt++) { |
| 68 | smatch match; |
| 69 | string s(*opt); |
| 70 | if (regex_match(s, match, optregex)) { |
| 71 | options[string(match[1])] = match[2]; |
| 72 | } else { |
| 73 | cerr << "Cannot parse option: " << *opt << endl; |
| 74 | options["help"] = ""; |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | if (options.count("help")) { |
| 79 | cerr << |
| 80 | " --target=connstr postgres database to send queries to" << endl << |
| 81 | #ifdef HAVE_LIBSQLITE3 |
| 82 | " --sqlite=URI SQLite database to send queries to" << endl << |
| 83 | #endif |
| 84 | #ifdef HAVE_MONETDB |
| 85 | " --monetdb=connstr MonetDB database to send queries to" <<endl << |
| 86 | #endif |
| 87 | " --log-to=connstr log errors to postgres database" << endl << |
| 88 | " --seed=int seed RNG with specified int instead of PID" << endl << |
| 89 | " --dump-all-queries print queries as they are generated" << endl << |
| 90 | " --dump-all-graphs dump generated ASTs" << endl << |
| 91 | " --dry-run print queries instead of executing them" << endl << |
| 92 | " --exclude-catalog don't generate queries using catalog relations" << endl << |
| 93 | " --max-queries=long terminate after generating this many queries" << endl << |
| 94 | " --rng-state=string deserialize dumped rng state" << endl << |
| 95 | " --verbose emit progress output" << endl << |
| 96 | " --version print version information and exit" << endl << |
| 97 | " --help print available command line options and exit" << endl; |
| 98 | return 0; |
| 99 | } else if (options.count("version")) { |
| 100 | return 0; |
| 101 | } |
| 102 | |
| 103 | try |
| 104 | { |
| 105 | shared_ptr<schema> schema; |
| 106 | if (options.count("sqlite")) { |
| 107 | #ifdef HAVE_LIBSQLITE3 |
| 108 | schema = make_shared<schema_sqlite>(options["sqlite"], options.count("exclude-catalog")); |
| 109 | #else |
| 110 | cerr << "Sorry, " PACKAGE_NAME " was compiled without SQLite support." << endl; |
| 111 | return 1; |
| 112 | #endif |
| 113 | } |
| 114 | else if(options.count("monetdb")) { |
| 115 | #ifdef HAVE_MONETDB |
| 116 | schema = make_shared<schema_monetdb>(options["monetdb"]); |
| 117 | #else |
nothing calls this directly
no test coverage detected