summaryrefslogtreecommitdiffstats
path: root/lldb/source/Commands/CommandObjectHelp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Commands/CommandObjectHelp.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectHelp.cpp62
1 files changed, 47 insertions, 15 deletions
diff --git a/lldb/source/Commands/CommandObjectHelp.cpp b/lldb/source/Commands/CommandObjectHelp.cpp
index 14d1ae5a0b4..ad969dbfd8f 100644
--- a/lldb/source/Commands/CommandObjectHelp.cpp
+++ b/lldb/source/Commands/CommandObjectHelp.cpp
@@ -24,6 +24,37 @@ using namespace lldb_private;
// CommandObjectHelp
//-------------------------------------------------------------------------
+void
+CommandObjectHelp::GenerateAdditionalHelpAvenuesMessage (Stream *s,
+ const char* command,
+ const char* prefix,
+ const char* subcommand,
+ bool include_apropos,
+ bool include_type_lookup)
+{
+ if (s && command && *command)
+ {
+ s->Printf("'%s' is not a known command.\n", command);
+ if (prefix && *prefix)
+ {
+ s->Printf("Try '%shelp' to see a current list of commands.\n", prefix);
+ }
+ else
+ {
+ s->PutCString("Try 'help' to see a current list of commands.\n");
+ }
+
+ if (include_apropos)
+ {
+ s->Printf("Try 'apropos %s' for a list of related commands.\n", subcommand ? subcommand : command);
+ }
+ if (include_type_lookup)
+ {
+ s->Printf("Try 'type lookup %s' for information on types, methods, functions, modules, etc.", subcommand ? subcommand : command);
+ }
+ }
+}
+
CommandObjectHelp::CommandObjectHelp (CommandInterpreter &interpreter) :
CommandObjectParsed (interpreter,
"help",
@@ -92,9 +123,10 @@ CommandObjectHelp::DoExecute (Args& command, CommandReturnObject &result)
CommandObject *sub_cmd_obj = cmd_obj;
// Loop down through sub_command dictionaries until we find the command object that corresponds
// to the help command entered.
+ std::string sub_command;
for (size_t i = 1; i < argc && all_okay; ++i)
{
- std::string sub_command = command.GetArgumentAtIndex(i);
+ sub_command = command.GetArgumentAtIndex(i);
matches.Clear();
if (! sub_cmd_obj->IsMultiwordObject ())
{
@@ -133,21 +165,22 @@ CommandObjectHelp::DoExecute (Args& command, CommandReturnObject &result)
}
else if (!sub_cmd_obj)
{
- result.AppendErrorWithFormat("'%s' is not a known command.\n"
- "Try '%shelp' to see a current list of commands.\n",
- cmd_string.c_str(),
- m_interpreter.GetCommandPrefix());
+ StreamString error_msg_stream;
+ GenerateAdditionalHelpAvenuesMessage(&error_msg_stream,
+ cmd_string.c_str(),
+ m_interpreter.GetCommandPrefix(),
+ sub_command.c_str());
+ result.AppendErrorWithFormat("%s",error_msg_stream.GetData());
result.SetStatus (eReturnStatusFailed);
return false;
}
else
{
- result.GetOutputStream().Printf("'%s' is not a known command.\n"
- "Try '%shelp' to see a current list of commands.\n"
- "The closest match is '%s'. Help on it follows.\n\n",
- cmd_string.c_str(),
- m_interpreter.GetCommandPrefix(),
- sub_cmd_obj->GetCommandName());
+ GenerateAdditionalHelpAvenuesMessage(&result.GetOutputStream(),
+ cmd_string.c_str(),
+ m_interpreter.GetCommandPrefix(),
+ sub_command.c_str());
+ result.GetOutputStream().Printf("\nThe closest match is '%s'. Help on it follows.\n\n", sub_cmd_obj->GetCommandName());
}
}
@@ -182,10 +215,9 @@ CommandObjectHelp::DoExecute (Args& command, CommandReturnObject &result)
}
else
{
- result.AppendErrorWithFormat
- ("'%s' is not a known command.\nTry '%shelp' to see a current list of commands.\n",
- command.GetArgumentAtIndex(0),
- m_interpreter.GetCommandPrefix());
+ StreamString error_msg_stream;
+ GenerateAdditionalHelpAvenuesMessage(&error_msg_stream, command.GetArgumentAtIndex(0), m_interpreter.GetCommandPrefix());
+ result.AppendErrorWithFormat("%s",error_msg_stream.GetData());
result.SetStatus (eReturnStatusFailed);
}
}
OpenPOWER on IntegriCloud