Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a help string when registering commands #154

Merged
merged 2 commits into from
May 6, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion fblldb.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also use str.splitlines() here instead, unless the maxsplit=1 here is important to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's definitely more readable. The use of maxsplit was to avoid doing more work than necessary.


key = filename + '_' + name

Expand All @@ -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):
Expand Down