Skip to content
New issue

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

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

Already on GitHub? # to your account

add ppath command #72

Merged
merged 7 commits into from
Mar 28, 2015
Merged
Changes from all commits
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
27 changes: 27 additions & 0 deletions commands/FBPrintCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def lldbcommands():
FBPrintInternals(),
FBPrintInstanceVariable(),
FBPrintKeyPath(),
FBPrintApplicationDocumentsPath(),
FBPrintData(),
]

Expand Down Expand Up @@ -301,6 +302,32 @@ def run(self, arguments, options):
printCommand = 'po [{} valueForKeyPath:@"{}"]'.format(object, keypath)
lldb.debugger.HandleCommand(printCommand)


class FBPrintApplicationDocumentsPath(fb.FBCommand):
def name(self):
return 'pdocspath'

def description(self):
return "Print application's 'Documents' directory path."

def options(self):
return [
fb.FBCommandArgument(short='-o', long='--open', arg='open', boolean=True, default=False, help='open in Finder'),
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

]

def run(self, arguments, options):
# in iOS SDK NSDocumentDirectory == 9 NSUserDomainMask == 1
NSDocumentDirectory = '9'
NSUserDomainMask = '1'
path = fb.evaluateExpressionValue('(NSString*)[NSSearchPathForDirectoriesInDomains(' + NSDocumentDirectory + ', ' + NSUserDomainMask + ', YES) lastObject]')
pathString = '{}'.format(path).split('"')[1]
cmd = 'echo {} | tr -d "\n" | pbcopy'.format(pathString)
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be echo -n to avoid the tr piece.

Copy link
Author

Choose a reason for hiding this comment

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

I don't know why echo -n just doesn't work as os.system()'s parameter. The -n will be taken as part of pathString and copied into pasteboard

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems /bin/sh doesn't handle -n like bash and zsh do. Oh well. Thanks for trying.

os.system(cmd)
print pathString
if options.open:
os.system('open '+ pathString)


class FBPrintData(fb.FBCommand):
def name(self):
return 'pdata'
Expand Down