| 113 | } |
| 114 | |
| 115 | int main(int argc, char* argv[]) { |
| 116 | args::ArgumentParser parser("Lbug shell"); |
| 117 | args::Positional<std::string> inputDirFlag(parser, "databasePath", |
| 118 | "Path to the database. If not given or set to \":memory:\", the database will be opened " |
| 119 | "under in-memory mode."); |
| 120 | args::HelpFlag help(parser, "help", "Display this help menu", {'h', "help"}); |
| 121 | args::ValueFlag<uint64_t> bpSizeInMBFlag(parser, "", |
| 122 | "Size of buffer pool for default and large page sizes in megabytes", |
| 123 | {'d', "default_bp_size", "defaultbpsize"}, -1u); |
| 124 | args::ValueFlag<uint64_t> maxDBSize(parser, "max_db_size", |
| 125 | "Maximum size of the database in bytes", {"max_db_size", "maxdbsize"}, -1u); |
| 126 | args::Flag disableCompression(parser, "no_compression", "Disable compression", |
| 127 | {"no_compression", "nocompression"}); |
| 128 | args::Flag readOnlyMode(parser, "read_only", "Open database at read-only mode.", |
| 129 | {'r', "read_only", "readonly"}); |
| 130 | args::ValueFlag<std::string> historyPathFlag(parser, "", "Path to directory for shell history", |
| 131 | {'p', "path_history"}); |
| 132 | args::Flag version(parser, "version", "Display current database version", {'v', "version"}); |
| 133 | args::ValueFlag<std::string> mode(parser, "", "Set the output mode of the shell", |
| 134 | {'m', "mode"}); |
| 135 | args::Flag stats(parser, "no_stats", "Disable query stats", {'s', "no_stats", "nostats"}); |
| 136 | args::Flag progress_bar(parser, "no_progress_bar", "Disable query progress bar", |
| 137 | {'b', "no_progress_bar", "noprogressbar"}); |
| 138 | args::Flag ignore_wal_replay_errors(parser, "ignore_wal_replay_errors", |
| 139 | "By default something goes wrong when replaying the WAL an exception will be thrown. With " |
| 140 | "this flag enabled we will instead ignore these errors and stop replaying the WAL.", |
| 141 | {'w', "ignore_wal_replay_errors"}); |
| 142 | args::ValueFlag<std::string> init(parser, "", "Path to file with script to run on startup", |
| 143 | {'i', "init"}); |
| 144 | |
| 145 | std::vector<std::string> lCaseArgsStrings; |
| 146 | for (auto i = 0; i < argc; ++i) { |
| 147 | std::string arg = argv[i]; |
| 148 | if (arg.size() > 1 && arg[0] == '-') { |
| 149 | std::string lArg = arg; |
| 150 | std::transform(lArg.begin(), lArg.end(), lArg.begin(), |
| 151 | [](unsigned char c) { return std::tolower(c); }); |
| 152 | lCaseArgsStrings.push_back(lArg); |
| 153 | } else { |
| 154 | lCaseArgsStrings.push_back(argv[i]); |
| 155 | } |
| 156 | } |
| 157 | std::vector<char*> lCaseArgs; |
| 158 | for (auto& arg : lCaseArgsStrings) { |
| 159 | lCaseArgs.push_back(const_cast<char*>(arg.c_str())); |
| 160 | } |
| 161 | |
| 162 | try { |
| 163 | parser.ParseCLI(lCaseArgs.size(), lCaseArgs.data()); |
| 164 | } catch (const args::Help&) { |
| 165 | std::cout << parser; |
| 166 | return 0; |
| 167 | } catch (const args::ParseError& e) { |
| 168 | std::cerr << e.what() << '\n'; |
| 169 | std::cerr << parser; |
| 170 | return 1; |
| 171 | } |
| 172 |
nothing calls this directly
no test coverage detected