diff options
author | Enrico Granata <egranata@apple.com> | 2013-06-12 01:50:57 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2013-06-12 01:50:57 +0000 |
commit | 9b62d1d5ee32ec7abca5ed2fdfc079aab2168c2a (patch) | |
tree | 4a81d561c8821dd14d627e1daf6580ad238f508a /lldb/source/Interpreter/CommandObject.cpp | |
parent | f045007f117f91656a5d16ae004cfc3934c61c70 (diff) | |
download | llvm-9b62d1d5ee32ec7abca5ed2fdfc079aab2168c2a.zip llvm-9b62d1d5ee32ec7abca5ed2fdfc079aab2168c2a.tar.gz llvm-9b62d1d5ee32ec7abca5ed2fdfc079aab2168c2a.tar.bz2 |
<rdar://problem/11914077>
If you type help command <word> <word> <word> <missingSubCommand> (e.g. help script import or help type summary fake), you will get help on the deepest matched command word (i.e. script or type summary in the examples)
Also, reworked the logic for commands to produce their help to make it more object-oriented
llvm-svn: 183822
Diffstat (limited to 'lldb/source/Interpreter/CommandObject.cpp')
-rw-r--r-- | lldb/source/Interpreter/CommandObject.cpp | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp index 6875605..67d57f1 100644 --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -903,6 +903,83 @@ ExprPathHelpTextCallback() } void +CommandObject::GenerateHelpText (CommandReturnObject &result) +{ + GenerateHelpText(result.GetOutputStream()); + + result.SetStatus (eReturnStatusSuccessFinishNoResult); +} + +void +CommandObject::GenerateHelpText (Stream &output_strm) +{ + CommandInterpreter& interpreter = GetCommandInterpreter(); + if (GetOptions() != NULL) + { + if (WantsRawCommandString()) + { + std::string help_text (GetHelp()); + help_text.append (" This command takes 'raw' input (no need to quote stuff)."); + interpreter.OutputFormattedHelpText (output_strm, "", "", help_text.c_str(), 1); + } + else + interpreter.OutputFormattedHelpText (output_strm, "", "", GetHelp(), 1); + output_strm.Printf ("\nSyntax: %s\n", GetSyntax()); + GetOptions()->GenerateOptionUsage (output_strm, this); + const char *long_help = GetHelpLong(); + if ((long_help != NULL) + && (strlen (long_help) > 0)) + output_strm.Printf ("\n%s", long_help); + if (WantsRawCommandString() && !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. + 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 (GetNumArgumentEntries() > 0 + && GetOptions() + && GetOptions()->NumCommandOptions() > 0) + { + // Also emit a warning about using "--" in case you are using a command that takes options and arguments. + 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); + } + } + else if (IsMultiwordObject()) + { + if (WantsRawCommandString()) + { + std::string help_text (GetHelp()); + help_text.append (" This command takes 'raw' input (no need to quote stuff)."); + interpreter.OutputFormattedHelpText (output_strm, "", "", help_text.c_str(), 1); + } + else + interpreter.OutputFormattedHelpText (output_strm, "", "", GetHelp(), 1); + GenerateHelpText (output_strm); + } + else + { + const char *long_help = GetHelpLong(); + if ((long_help != NULL) + && (strlen (long_help) > 0)) + output_strm.Printf ("%s", long_help); + else if (WantsRawCommandString()) + { + std::string help_text (GetHelp()); + help_text.append (" This command takes 'raw' input (no need to quote stuff)."); + interpreter.OutputFormattedHelpText (output_strm, "", "", help_text.c_str(), 1); + } + else + interpreter.OutputFormattedHelpText (output_strm, "", "", GetHelp(), 1); + output_strm.Printf ("\nSyntax: %s\n", GetSyntax()); + } +} + +void CommandObject::AddIDsArgumentData(CommandArgumentEntry &arg, CommandArgumentType ID, CommandArgumentType IDRange) { CommandArgumentData id_arg; |