Skip to content

Commit 96b753d

Browse files
author
Dave Lee
committed
Clean up findinstance argument handling
1 parent 53536f0 commit 96b753d

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

commands/FBDebugCommands.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,13 @@ class FBFindInstancesCommand(fb.FBCommand):
193193
def name(self):
194194
return 'findinstances'
195195

196+
def args(self):
197+
return [
198+
fb.FBCommandArgument(arg='type' help='Class or protocol name'),
199+
fb.FBCommandArgument(arg='query', default=' ', # space is a hack to mark optional
200+
help='Query expression, uses NSPredicate syntax')
201+
]
202+
196203
def description(self):
197204
return """
198205
Find instances of specified ObjC classes.
@@ -240,16 +247,10 @@ def run(self, arguments, options):
240247
print 'Usage: findinstances <classOrProtocol> [<predicate>]; Run `help findinstances`'
241248
return
242249

243-
# Unpack the arguments by hand. The input is entirely in arguments[0].
244-
args = arguments[0].strip().split(' ', 1)
245-
246-
query = args[0]
247-
if len(args) > 1:
248-
predicate = args[1].strip()
249-
# Escape double quotes and backslashes.
250-
predicate = re.sub('([\\"])', r'\\\1', predicate)
251-
else:
252-
predicate = ''
250+
query = arguments[0]
251+
predicate = arguments[1].strip()
252+
# Escape double quotes and backslashes.
253+
predicate = re.sub('([\\"])', r'\\\1', predicate)
253254
call = '(void)PrintInstances("{}", "{}")'.format(query, predicate)
254255
fb.evaluateExpressionValue(call)
255256

0 commit comments

Comments
 (0)