| 219 | } |
| 220 | |
| 221 | optional_ptr<const CommandLineOption> ShellState::FindCommandLineOption(const string &option, string &error_msg) const { |
| 222 | auto c = FindOption(option.c_str()); |
| 223 | if (!c.IsValid()) { |
| 224 | // we haven't found it yet - try substituting all underscores with dashes |
| 225 | // this is legacy behavior - we allow e.g. "-storage_version" to be used instead of "-storage-version" |
| 226 | auto option_name = StringUtil::Replace(option, "_", "-"); |
| 227 | c = FindOption(option_name.c_str()); |
| 228 | } |
| 229 | if (!c.IsValid()) { |
| 230 | // not found |
| 231 | error_msg = StringUtil::Format("Unknown Option Error: Unrecognized option '-%s'\n", option); |
| 232 | vector<string> option_names; |
| 233 | for (idx_t c = 0; command_line_options[c].option; c++) { |
| 234 | auto &option = command_line_options[c]; |
| 235 | option_names.push_back(string("-") + option.option); |
| 236 | } |
| 237 | auto candidates_msg = StringUtil::CandidatesErrorMessage(option_names, "-" + option, "Did you mean"); |
| 238 | error_msg += candidates_msg + "\n"; |
| 239 | error_msg += StringUtil::Format("Run '%s -help' for a list of options.\n", program_name); |
| 240 | return nullptr; |
| 241 | } |
| 242 | return command_line_options[c.GetIndex()]; |
| 243 | } |
| 244 | |
| 245 | struct PrintOptionInfo { |
| 246 | string command_name; |