Index: lldb/include/lldb/Interpreter/CommandInterpreter.h =================================================================== --- lldb/include/lldb/Interpreter/CommandInterpreter.h +++ lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -498,6 +498,14 @@ return m_user_dict; } + const CommandObject::CommandMap &GetCommands() const { + return m_command_dict; + } + + const CommandObject::CommandMap &GetAliases() const { + return m_alias_dict; + } + /// Specify if the command interpreter should allow that the user can /// specify a custom exit code when calling 'quit'. void AllowExitCodeOnQuit(bool allow); Index: lldb/source/Commands/CommandObjectCommands.cpp =================================================================== --- lldb/source/Commands/CommandObjectCommands.cpp +++ lldb/source/Commands/CommandObjectCommands.cpp @@ -767,6 +767,19 @@ ~CommandObjectCommandsUnalias() override = default; + void + HandleArgumentCompletion(CompletionRequest &request, + OptionElementVector &opt_element_vector) override { + + if (!m_interpreter.HasCommands() || request.GetCursorIndex() != 0) + return; + const auto &alias_dict = m_interpreter.GetAliases(); + + for (auto pos = alias_dict.begin(); pos != alias_dict.end(); ++pos) { + request.TryCompleteCurrentArg(pos->first, pos->second->GetHelp()); + } + } + protected: bool DoExecute(Args &args, CommandReturnObject &result) override { CommandObject::CommandMap::iterator pos; @@ -848,6 +861,20 @@ ~CommandObjectCommandsDelete() override = default; + void + HandleArgumentCompletion(CompletionRequest &request, + OptionElementVector &opt_element_vector) override { + + if (!m_interpreter.HasCommands() || request.GetCursorIndex() != 0) + return; + const auto &cmd_dict = m_interpreter.GetCommands(); + + for (auto pos = cmd_dict.begin(); pos != cmd_dict.end(); ++pos) { + if(pos->second->IsRemovable()) + request.TryCompleteCurrentArg(pos->first, pos->second->GetHelp()); + } + } + protected: bool DoExecute(Args &args, CommandReturnObject &result) override { CommandObject::CommandMap::iterator pos; Index: lldb/test/API/functionalities/completion/TestCompletion.py =================================================================== --- lldb/test/API/functionalities/completion/TestCompletion.py +++ lldb/test/API/functionalities/completion/TestCompletion.py @@ -375,6 +375,13 @@ self.runCmd("command script add -h test_desc -f none -s current usercmd1") self.check_completion_with_desc('command script delete ', [['usercmd1', 'test_desc']]) + def test_command_delete(self): + self.runCmd(r"command regex f s/^$/finish/ 's/([0-9]+)/frame select %1/'") + self.complete_from_to('command delete ', ['f']) + + def test_command_unalias(self): + self.complete_from_to('command unalias ima', 'command unalias image') + def test_completion_description_commands(self): """Test descriptions of top-level command completions""" self.check_completion_with_desc("", [