aboutsummaryrefslogtreecommitdiff
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.cpp92
1 files changed, 16 insertions, 76 deletions
diff --git a/lldb/source/Commands/CommandObjectHelp.cpp b/lldb/source/Commands/CommandObjectHelp.cpp
index 00e2551..7d638a4 100644
--- a/lldb/source/Commands/CommandObjectHelp.cpp
+++ b/lldb/source/Commands/CommandObjectHelp.cpp
@@ -119,13 +119,7 @@ CommandObjectHelp::DoExecute (Args& command, CommandReturnObject &result)
{
std::string cmd_string;
command.GetCommandString (cmd_string);
- if (matches.GetSize() < 2)
- {
- result.AppendErrorWithFormat("'%s' is not a known command.\n"
- "Try 'help' to see a current list of commands.\n",
- cmd_string.c_str());
- }
- else
+ if (matches.GetSize() >= 2)
{
StreamString s;
s.Printf ("ambiguous command %s", cmd_string.c_str());
@@ -136,83 +130,29 @@ CommandObjectHelp::DoExecute (Args& command, CommandReturnObject &result)
}
s.Printf ("\n");
result.AppendError(s.GetData());
+ result.SetStatus (eReturnStatusFailed);
+ return false;
}
-
- result.SetStatus (eReturnStatusFailed);
- }
- else
- {
- Stream &output_strm = result.GetOutputStream();
- if (sub_cmd_obj->GetOptions() != NULL)
- {
- if (sub_cmd_obj->WantsRawCommandString())
- {
- std::string help_text (sub_cmd_obj->GetHelp());
- help_text.append (" This command takes 'raw' input (no need to quote stuff).");
- m_interpreter.OutputFormattedHelpText (output_strm, "", "", help_text.c_str(), 1);
- }
- else
- m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1);
- output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax());
- sub_cmd_obj->GetOptions()->GenerateOptionUsage (output_strm, sub_cmd_obj);
- const char *long_help = sub_cmd_obj->GetHelpLong();
- if ((long_help != NULL)
- && (strlen (long_help) > 0))
- output_strm.Printf ("\n%s", long_help);
- if (sub_cmd_obj->WantsRawCommandString() && !sub_cmd_obj->WantsCompletion())
- {
- // Emit the message about using ' -- ' between the end of the command options and the raw input
- // conditionally, i.e., only if the command object does not want completion.
- m_interpreter.OutputFormattedHelpText (output_strm, "", "",
- "\nIMPORTANT NOTE: Because this command takes 'raw' input, if you use any command options"
- " you must use ' -- ' between the end of the command options and the beginning of the raw input.", 1);
- }
- else if (sub_cmd_obj->GetNumArgumentEntries() > 0
- && sub_cmd_obj->GetOptions()
- && sub_cmd_obj->GetOptions()->NumCommandOptions() > 0)
- {
- // Also emit a warning about using "--" in case you are using a command that takes options and arguments.
- m_interpreter.OutputFormattedHelpText (output_strm, "", "",
- "\nThis command takes options and free-form arguments. If your arguments resemble"
- " option specifiers (i.e., they start with a - or --), you must use ' -- ' between"
- " the end of the command options and the beginning of the arguments.", 1);
- }
-
- // Mark this help command with a success status.
- result.SetStatus (eReturnStatusSuccessFinishNoResult);
- }
- else if (sub_cmd_obj->IsMultiwordObject())
+ else if (!sub_cmd_obj)
{
- if (sub_cmd_obj->WantsRawCommandString())
- {
- std::string help_text (sub_cmd_obj->GetHelp());
- help_text.append (" This command takes 'raw' input (no need to quote stuff).");
- m_interpreter.OutputFormattedHelpText (output_strm, "", "", help_text.c_str(), 1);
- }
- else
- m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1);
- sub_cmd_obj->GenerateHelpText (result);
+ result.AppendErrorWithFormat("'%s' is not a known command.\n"
+ "Try 'help' to see a current list of commands.\n",
+ cmd_string.c_str());
+ result.SetStatus (eReturnStatusFailed);
+ return false;
}
else
{
- const char *long_help = sub_cmd_obj->GetHelpLong();
- if ((long_help != NULL)
- && (strlen (long_help) > 0))
- output_strm.Printf ("%s", long_help);
- else if (sub_cmd_obj->WantsRawCommandString())
- {
- std::string help_text (sub_cmd_obj->GetHelp());
- help_text.append (" This command takes 'raw' input (no need to quote stuff).");
- m_interpreter.OutputFormattedHelpText (output_strm, "", "", help_text.c_str(), 1);
- }
- else
- m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1);
- output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax());
- // Mark this help command with a success status.
- result.SetStatus (eReturnStatusSuccessFinishNoResult);
+ result.GetOutputStream().Printf("'%s' is not a known command.\n"
+ "Try 'help' to see a current list of commands.\n"
+ "The closest match is '%s'. Help on it follows.\n\n",
+ cmd_string.c_str(),
+ sub_cmd_obj->GetCommandName());
}
}
+ sub_cmd_obj->GenerateHelpText(result);
+
if (is_alias_command)
{
StreamString sstr;