Adding two new options to the 'help' command:
--show-aliases (-a) shows aliases for commands, as well as built-in commands
--hide-user-defined (-u) hides user defined commands
by default 'help' without arguments does not show aliases anymore. to see them, add --show-aliases
to have only built-in commands appear, use 'help --hide-user-defined' ; there is currently no way to hide
built-in commands from the help output
'help command' is not changed by this commit, and help is shown even if command is an alias and -a is not specified
llvm-svn: 139377
diff --git a/lldb/source/Commands/CommandObjectHelp.h b/lldb/source/Commands/CommandObjectHelp.h
index 9e6c90b..c089048 100644
--- a/lldb/source/Commands/CommandObjectHelp.h
+++ b/lldb/source/Commands/CommandObjectHelp.h
@@ -15,6 +15,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Interpreter/CommandObject.h"
+#include "lldb/Interpreter/Options.h"
namespace lldb_private {
@@ -43,6 +44,71 @@
int max_return_elements,
bool &word_complete,
StringList &matches);
+
+ class CommandOptions : public Options
+ {
+ public:
+
+ CommandOptions (CommandInterpreter &interpreter) :
+ Options (interpreter)
+ {
+ }
+
+ virtual
+ ~CommandOptions (){}
+
+ virtual Error
+ SetOptionValue (uint32_t option_idx, const char *option_arg)
+ {
+ Error error;
+ char short_option = (char) m_getopt_table[option_idx].val;
+
+ switch (short_option)
+ {
+ case 'a':
+ m_show_aliases = true;
+ break;
+ case 'u':
+ m_show_user_defined = false;
+ break;
+ default:
+ error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
+ break;
+ }
+
+ return error;
+ }
+
+ void
+ OptionParsingStarting ()
+ {
+ m_show_aliases = false;
+ m_show_user_defined = true;
+ }
+
+ const OptionDefinition*
+ GetDefinitions ()
+ {
+ return g_option_table;
+ }
+
+ // Options table: Required for subclasses of Options.
+
+ static OptionDefinition g_option_table[];
+
+ // Instance variables to hold the values for command options.
+
+ bool m_show_aliases;
+ bool m_show_user_defined;
+ };
+
+ CommandOptions m_options;
+
+ virtual Options *
+ GetOptions ()
+ {
+ return &m_options;
+ }
};