diff options
Diffstat (limited to 'source/Commands/CommandObjectApropos.cpp')
-rw-r--r-- | source/Commands/CommandObjectApropos.cpp | 51 |
1 files changed, 8 insertions, 43 deletions
diff --git a/source/Commands/CommandObjectApropos.cpp b/source/Commands/CommandObjectApropos.cpp index 47890b1e83b74..29e1f14e3b28a 100644 --- a/source/Commands/CommandObjectApropos.cpp +++ b/source/Commands/CommandObjectApropos.cpp @@ -7,16 +7,14 @@ // //===----------------------------------------------------------------------===// -#include "CommandObjectApropos.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "CommandObjectApropos.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/Options.h" #include "lldb/Interpreter/Property.h" - #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -27,11 +25,8 @@ using namespace lldb_private; // CommandObjectApropos //------------------------------------------------------------------------- -CommandObjectApropos::CommandObjectApropos (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "apropos", - "Find a list of debugger commands related to a particular word/subject.", - NULL) +CommandObjectApropos::CommandObjectApropos(CommandInterpreter &interpreter) + : CommandObjectParsed(interpreter, "apropos", "List debugger commands related to a word or subject.", nullptr) { CommandArgumentEntry arg; CommandArgumentData search_word_arg; @@ -47,10 +42,7 @@ CommandObjectApropos::CommandObjectApropos (CommandInterpreter &interpreter) : m_arguments.push_back (arg); } -CommandObjectApropos::~CommandObjectApropos() -{ -} - +CommandObjectApropos::~CommandObjectApropos() = default; bool CommandObjectApropos::DoExecute (Args& args, CommandReturnObject &result) @@ -60,20 +52,17 @@ CommandObjectApropos::DoExecute (Args& args, CommandReturnObject &result) if (argc == 1) { const char *search_word = args.GetArgumentAtIndex(0); - if ((search_word != NULL) + if ((search_word != nullptr) && (strlen (search_word) > 0)) { // The bulk of the work must be done inside the Command Interpreter, since the command dictionary // is private. StringList commands_found; StringList commands_help; - StringList user_commands_found; - StringList user_commands_help; - m_interpreter.FindCommandsForApropos (search_word, commands_found, commands_help, true, false); - m_interpreter.FindCommandsForApropos (search_word, user_commands_found, user_commands_help, false, true); + m_interpreter.FindCommandsForApropos (search_word, commands_found, commands_help, true, true, true); - if (commands_found.GetSize() == 0 && user_commands_found.GetSize() == 0) + if (commands_found.GetSize() == 0) { result.AppendMessageWithFormat ("No commands found pertaining to '%s'. Try 'help' to see a complete list of debugger commands.\n", search_word); } @@ -81,7 +70,7 @@ CommandObjectApropos::DoExecute (Args& args, CommandReturnObject &result) { if (commands_found.GetSize() > 0) { - result.AppendMessageWithFormat ("The following built-in commands may relate to '%s':\n", search_word); + result.AppendMessageWithFormat ("The following commands may relate to '%s':\n", search_word); size_t max_len = 0; for (size_t i = 0; i < commands_found.GetSize(); ++i) @@ -97,33 +86,9 @@ CommandObjectApropos::DoExecute (Args& args, CommandReturnObject &result) "--", commands_help.GetStringAtIndex(i), max_len); - if (user_commands_found.GetSize() > 0) - result.AppendMessage(""); - } - - if (user_commands_found.GetSize() > 0) - { - result.AppendMessageWithFormat ("The following user commands may relate to '%s':\n", search_word); - size_t max_len = 0; - - for (size_t i = 0; i < user_commands_found.GetSize(); ++i) - { - size_t len = strlen (user_commands_found.GetStringAtIndex (i)); - if (len > max_len) - max_len = len; - } - - for (size_t i = 0; i < user_commands_found.GetSize(); ++i) - m_interpreter.OutputFormattedHelpText (result.GetOutputStream(), - user_commands_found.GetStringAtIndex(i), - "--", - user_commands_help.GetStringAtIndex(i), - max_len); } - } - std::vector<const Property *> properties; const size_t num_properties = m_interpreter.GetDebugger().Apropos(search_word, properties); if (num_properties) |