From caa10f2ea7cedcda717d85843eba76b372f27c52 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Fri, 6 May 2016 15:44:16 -0700 Subject: [PATCH 1/2] Provide a help string when registering commands I don't know when it was added, but `command script add` has a --help flag, which defines the help text to show in the output of the `help` command. This change calls the description method on each command, extracts the first line, and then passes that as the help string when registering the command. --- fblldb.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) mode change 100644 => 100755 fblldb.py diff --git a/fblldb.py b/fblldb.py old mode 100644 new mode 100755 index 6795bb9..a4f6600 --- a/fblldb.py +++ b/fblldb.py @@ -41,6 +41,7 @@ def loadCommandsInDirectory(commandsDirectory): def loadCommand(module, command, directory, filename, extension): func = makeRunCommand(command, os.path.join(directory, filename + extension)) name = command.name() + helpText = command.description().split('\n', 1)[0] # first line of description key = filename + '_' + name @@ -49,7 +50,10 @@ def loadCommand(module, command, directory, filename, extension): functionName = '__' + key lldb.debugger.HandleCommand('script ' + functionName + ' = sys.modules[\'' + module.__name__ + '\']._loadedFunctions[\'' + key + '\']') - lldb.debugger.HandleCommand('command script add -f ' + functionName + ' ' + name) + lldb.debugger.HandleCommand('command script add --help "{help}" --function {function} {name}'.format( + help=helpText.replace('"', '\\"'), # escape quotes + function=functionName, + name=name)) def makeRunCommand(command, filename): def runCommand(debugger, input, result, dict): From e95985786e07646ed984f8c4071382c1e5ded6e2 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Fri, 6 May 2016 15:56:06 -0700 Subject: [PATCH 2/2] Use splitlines for readability --- fblldb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fblldb.py b/fblldb.py index a4f6600..72a41f0 100755 --- a/fblldb.py +++ b/fblldb.py @@ -41,7 +41,7 @@ def loadCommandsInDirectory(commandsDirectory): def loadCommand(module, command, directory, filename, extension): func = makeRunCommand(command, os.path.join(directory, filename + extension)) name = command.name() - helpText = command.description().split('\n', 1)[0] # first line of description + helpText = command.description().splitlines()[0] # first line of description key = filename + '_' + name