MCPcopy Create free account
hub / github.com/baidu/tera / PromptSimilarCmd

Function PromptSimilarCmd

src/admincli.cc:1856–1874  ·  view source on GitHub ↗

return false if similar command(s) not found

Source from the content-addressed store, hash-verified

1854
1855// return false if similar command(s) not found
1856static bool PromptSimilarCmd(const char* msg) {
1857 if (msg == NULL) {
1858 return false;
1859 }
1860 bool found = false;
1861 int64_t len = strlen(msg);
1862 int64_t threshold = int64_t((len * 0.3 < 3) ? 3 : len * 0.3);
1863 int count = sizeof(builtin_cmd_list) / sizeof(char*);
1864 for (int i = 0; i < count; i += 2) {
1865 if (EditDistance(msg, builtin_cmd_list[i]) <= threshold) {
1866 if (!found) {
1867 std::cout << "Did you mean:" << std::endl;
1868 found = true;
1869 }
1870 std::cout << " " << builtin_cmd_list[i] << std::endl;
1871 }
1872 }
1873 return found;
1874}
1875
1876static void PrintUnknownCmdHelpInfo(const char* msg) {
1877 if (msg != NULL) {

Callers 1

PrintUnknownCmdHelpInfoFunction · 0.70

Calls 1

EditDistanceFunction · 0.85

Tested by

no test coverage detected