diff options
author | Enrico Granata <egranata@apple.com> | 2015-03-13 22:22:28 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2015-03-13 22:22:28 +0000 |
commit | 6f79bb2d57218e2bd11bf26876d49a1276328bd3 (patch) | |
tree | 8e1121c0e0e91538662d0d8b34ac329053ebc14c /lldb/source/Commands/CommandObjectCommands.cpp | |
parent | e7ce9ec398103c59b18993ef637fd1aab32c0710 (diff) | |
download | llvm-6f79bb2d57218e2bd11bf26876d49a1276328bd3.zip llvm-6f79bb2d57218e2bd11bf26876d49a1276328bd3.tar.gz llvm-6f79bb2d57218e2bd11bf26876d49a1276328bd3.tar.bz2 |
Add support for Python object commands to return custom short and long help by implementing
def get_short_help(self)
def get_long_help(self)
methods on the command object
Also, add a test case for this feature
llvm-svn: 232224
Diffstat (limited to 'lldb/source/Commands/CommandObjectCommands.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectCommands.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index febbfa8..92e8670 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -1435,6 +1435,8 @@ class CommandObjectScriptingObject : public CommandObjectRaw private: lldb::ScriptInterpreterObjectSP m_cmd_obj_sp; ScriptedCommandSynchronicity m_synchro; + bool m_fetched_help_short:1; + bool m_fetched_help_long:1; public: @@ -1447,7 +1449,9 @@ public: NULL, NULL), m_cmd_obj_sp(cmd_obj_sp), - m_synchro(synch) + m_synchro(synch), + m_fetched_help_short(false), + m_fetched_help_long(false) { StreamString stream; stream.Printf("For more information run 'help %s'",name.c_str()); @@ -1476,10 +1480,38 @@ public: { return m_synchro; } + + virtual const char * + GetHelp () + { + if (!m_fetched_help_short) + { + ScriptInterpreter* scripter = m_interpreter.GetScriptInterpreter(); + if (scripter) + { + std::string docstring; + m_fetched_help_short = scripter->GetShortHelpForCommandObject(m_cmd_obj_sp,docstring); + if (!docstring.empty()) + SetHelp(docstring); + } + } + return CommandObjectRaw::GetHelp(); + } virtual const char * GetHelpLong () { + if (!m_fetched_help_long) + { + ScriptInterpreter* scripter = m_interpreter.GetScriptInterpreter(); + if (scripter) + { + std::string docstring; + m_fetched_help_long = scripter->GetLongHelpForCommandObject(m_cmd_obj_sp,docstring); + if (!docstring.empty()) + SetHelpLong(docstring); + } + } return CommandObjectRaw::GetHelpLong(); } |