import lldb
import commands
import optparse
import shlex
def ls(debugger, command, result, dict):
command_args = shlex.split(command)
usage = "usage: %prog [options] <PATH> [PATH ...]"
description='''This command lets you run the /bin/ls command from within lldb as a quick and easy example.'''
parser = optparse.OptionParser(description=description, prog='ls',usage=usage)
parser.add_option('-v', '--verbose', action='store_true', dest='verbose', help='display verbose debug info', default=False)
try:
(options, args) = parser.parse_args(command_args)
except:
return
for arg in args:
if options.verbose:
result.PutCString(commands.getoutput('/bin/ls "%s"' % arg))
else:
result.PutCString(commands.getoutput('/bin/ls -lAF "%s"' % arg))
if __name__ == '__main__':
lldb.debugger = lldb.SBDebugger.Create()
ls (sys.argv)
def __lldb_init_module (debugger, dict):
debugger.HandleCommand('command script add -f cmdtemplate.ls ls')
print '"ls" command installed, type "ls --help" for detailed help'