summaryrefslogtreecommitdiffstats
path: root/lldb/source/Commands/CommandObjectHelp.cpp
diff options
context:
space:
mode:
authorCaroline Tice <ctice@apple.com>2010-10-01 17:46:38 +0000
committerCaroline Tice <ctice@apple.com>2010-10-01 17:46:38 +0000
commite139cf23208310d335f52eab5a177401944ce00e (patch)
tree55f4fe47b52d9963942d4188fb3cc4aca78828a7 /lldb/source/Commands/CommandObjectHelp.cpp
parentb5051dc5298be449610939a9bb28cf65aa47c179 (diff)
downloadbcm5719-llvm-e139cf23208310d335f52eab5a177401944ce00e.tar.gz
bcm5719-llvm-e139cf23208310d335f52eab5a177401944ce00e.zip
Add infrastructure for standardizing arguments for commands and
command options; makes it easier to ensure that the same type of argument will have the same name everywhere, hooks up help for command arguments, so that users can ask for help when they are confused about what an argument should be; puts in the beginnings of the ability to do tab-completion for certain types of arguments, allows automatic syntax help generation for commands with arguments, and adds command arguments into command options help correctly. Currently only the breakpoint-id and breakpoint-id-range arguments, in the breakpoint commands, have been hooked up to use the new mechanism. The next steps will be to fix the command options arguments to use this mechanism, and to fix the rest of the regular command arguments to use this mechanism. Most of the help text is currently missing or dummy text; this will need to be filled in, and the existing argument help text will need to be cleaned up a bit (it was thrown in quickly, mostly for testing purposes). Help command now works for all argument types, although the help may not be very helpful yet. Those commands that take "raw" command strings now indicate it in their help text. llvm-svn: 115318
Diffstat (limited to 'lldb/source/Commands/CommandObjectHelp.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectHelp.cpp43
1 files changed, 37 insertions, 6 deletions
diff --git a/lldb/source/Commands/CommandObjectHelp.cpp b/lldb/source/Commands/CommandObjectHelp.cpp
index 2d4b9f28482..4f8b752a2ed 100644
--- a/lldb/source/Commands/CommandObjectHelp.cpp
+++ b/lldb/source/Commands/CommandObjectHelp.cpp
@@ -95,7 +95,14 @@ CommandObjectHelp::Execute (Args& command, CommandReturnObject &result)
Stream &output_strm = result.GetOutputStream();
if (sub_cmd_obj->GetOptions() != NULL)
{
- m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1);
+ 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 (m_interpreter, output_strm, sub_cmd_obj);
const char *long_help = sub_cmd_obj->GetHelpLong();
@@ -105,7 +112,14 @@ CommandObjectHelp::Execute (Args& command, CommandReturnObject &result)
}
else if (sub_cmd_obj->IsMultiwordObject())
{
- m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1);
+ 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);
((CommandObjectMultiword *) sub_cmd_obj)->GenerateHelpText (result);
}
else
@@ -114,6 +128,12 @@ CommandObjectHelp::Execute (Args& command, CommandReturnObject &result)
if ((long_help != NULL)
&& (strlen (long_help) > 0))
output_strm.Printf ("\n%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());
@@ -132,10 +152,21 @@ CommandObjectHelp::Execute (Args& command, CommandReturnObject &result)
}
else
{
- result.AppendErrorWithFormat
- ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n",
- command.GetArgumentAtIndex(0));
- result.SetStatus (eReturnStatusFailed);
+ // Maybe the user is asking for help about a command argument rather than a command.
+ const CommandArgumentType arg_type = CommandObject::LookupArgumentName (command.GetArgumentAtIndex (0));
+ if (arg_type != eArgTypeLastArg)
+ {
+ Stream &output_strm = result.GetOutputStream ();
+ CommandObject::GetArgumentHelp (output_strm, arg_type, m_interpreter);
+ result.SetStatus (eReturnStatusSuccessFinishNoResult);
+ }
+ else
+ {
+ result.AppendErrorWithFormat
+ ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n",
+ command.GetArgumentAtIndex(0));
+ result.SetStatus (eReturnStatusFailed);
+ }
}
}
OpenPOWER on IntegriCloud