From 6f79bb2d57218e2bd11bf26876d49a1276328bd3 Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Fri, 13 Mar 2015 22:22:28 +0000 Subject: 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 --- lldb/source/Commands/CommandObjectCommands.cpp | 34 +++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'lldb/source/Commands/CommandObjectCommands.cpp') 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(); } -- cgit v1.1