MCPcopy Create free account
hub / github.com/Icinga/icinga2 / ConsoleCompleteHelper

Method ConsoleCompleteHelper

lib/cli/consolecommand.cpp:183–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181
182#ifdef HAVE_EDITLINE
183char *ConsoleCommand::ConsoleCompleteHelper(const char *word, int state)
184{
185 static std::vector<String> matches;
186
187 if (state == 0) {
188 if (!l_Url)
189 matches = ConsoleHandler::GetAutocompletionSuggestions(word, *l_ScriptFrame);
190 else {
191 Array::Ptr suggestions;
192
193 /* Remote debug console. */
194 try {
195 suggestions = AutoCompleteScript(l_Session, word, l_ScriptFrame->Sandboxed);
196 } catch (...) {
197 return nullptr; //Errors are just ignored here.
198 }
199
200 matches.clear();
201
202 ObjectLock olock(suggestions);
203 std::copy(suggestions->Begin(), suggestions->End(), std::back_inserter(matches));
204 }
205 }
206
207 if (state >= static_cast<int>(matches.size()))
208 return nullptr;
209
210 return strdup(matches[state].CStr());
211}
212#endif /* HAVE_EDITLINE */
213
214/**

Callers

nothing calls this directly

Calls 5

CStrMethod · 0.80
clearMethod · 0.45
BeginMethod · 0.45
EndMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected