int CommandObject::HandleCompletion ( Args &input, int &cursor_index, int &cursor_char_position, int match_start_point, int max_return_elements, bool &word_complete, StringList &matches ) { // Default implmentation of WantsCompletion() is !WantsRawCommandString(). // Subclasses who want raw command string but desire, for example, // argument completion should override WantsCompletion() to return true, // instead. if (WantsRawCommandString() && !WantsCompletion()) { // FIXME: Abstract telling the completion to insert the completion character. matches.Clear(); return -1; } else { // Can we do anything generic with the options? Options *cur_options = GetOptions(); CommandReturnObject result; OptionElementVector opt_element_vector; if (cur_options != NULL) { // Re-insert the dummy command name string which will have been // stripped off: input.Unshift ("dummy-string"); cursor_index++; // I stick an element on the end of the input, because if the last element is // option that requires an argument, getopt_long will freak out. input.AppendArgument ("<FAKE-VALUE>"); input.ParseArgsForCompletion (*cur_options, opt_element_vector, cursor_index); input.DeleteArgumentAtIndex(input.GetArgumentCount() - 1); bool handled_by_options; handled_by_options = cur_options->HandleOptionCompletion (input, opt_element_vector, cursor_index, cursor_char_position, match_start_point, max_return_elements, word_complete, matches); if (handled_by_options) return matches.GetSize(); } // If we got here, the last word is not an option or an option argument. return HandleArgumentCompletion (input, cursor_index, cursor_char_position, opt_element_vector, match_start_point, max_return_elements, word_complete, matches); } }