MCPcopy Create free account
hub / github.com/duckdb/duckdb / FindCommandLineOption

Method FindCommandLineOption

tools/shell/shell_command_line_option.cpp:221–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

219}
220
221optional_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
245struct PrintOptionInfo {
246 string command_name;

Callers 1

RunShellFunction · 0.80

Calls 5

FindOptionFunction · 0.85
c_strMethod · 0.80
IsValidMethod · 0.45
push_backMethod · 0.45
GetIndexMethod · 0.45

Tested by

no test coverage detected