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
diff --git a/lldb/test/functionalities/command_script/TestCommandScript.py b/lldb/test/functionalities/command_script/TestCommandScript.py
index 9c1183a..b7e466d 100644
--- a/lldb/test/functionalities/command_script/TestCommandScript.py
+++ b/lldb/test/functionalities/command_script/TestCommandScript.py
@@ -119,7 +119,7 @@
self.runCmd("command script clear")
# Test that re-defining an existing command works
- self.runCmd('command script add my_command --function welcome.welcome_impl')
+ self.runCmd('command script add my_command --class welcome.WelcomeCommand')
self.expect('my_command Blah', substrs = ['Hello Blah, welcome to LLDB'])
self.runCmd('command script add my_command --function welcome.target_name_impl')
diff --git a/lldb/test/functionalities/command_script/py_import b/lldb/test/functionalities/command_script/py_import
index afc8c82..6150e02 100644
--- a/lldb/test/functionalities/command_script/py_import
+++ b/lldb/test/functionalities/command_script/py_import
@@ -2,7 +2,7 @@
script sys.path.append(os.path.join(os.getcwd(), os.pardir))
script import welcome
script import bug11569
-command script add welcome --function welcome.welcome_impl
+command script add welcome --class welcome.WelcomeCommand
command script add targetname --function welcome.target_name_impl
command script add longwait --function welcome.print_wait_impl
command script import mysto.py --allow-reload
diff --git a/lldb/test/functionalities/command_script/welcome.py b/lldb/test/functionalities/command_script/welcome.py
index c444934..90bd0b8 100644
--- a/lldb/test/functionalities/command_script/welcome.py
+++ b/lldb/test/functionalities/command_script/welcome.py
@@ -1,12 +1,15 @@
import sys
-def welcome_impl(debugger, args, result, dict):
- """
- Just a docstring for welcome_impl
- A command that says hello to LLDB users
- """
- print >>result, ('Hello ' + args + ', welcome to LLDB');
- return None;
+class WelcomeCommand(object):
+ def __init__(self, debugger, session_dict):
+ pass
+
+ def get_short_help(self):
+ return "Just a docstring for welcome_impl\nA command that says hello to LLDB users"
+
+ def __call__(self, debugger, args, exe_ctx, result):
+ print >>result, ('Hello ' + args + ', welcome to LLDB');
+ return None;
def target_name_impl(debugger, args, result, dict):
target = debugger.GetSelectedTarget()