comparison mxtool/mx.py @ 11203:8ab76b7c6ff6

added interactive selection capability to 'mx javap' command
author Doug Simon <doug.simon@oracle.com>
date Mon, 05 Aug 2013 14:00:14 +0200
parents be8b942f448f
children 13d0d29aa15c
comparison
equal deleted inserted replaced
11202:4c0f7b396be6 11203:8ab76b7c6ff6
3262 matches.append(classname) 3262 matches.append(classname)
3263 if logToConsole: 3263 if logToConsole:
3264 log(classname) 3264 log(classname)
3265 return matches 3265 return matches
3266 3266
3267 def select_items(candidates):
3268 """
3269 Presents a command line interface for selecting one or more items from a sequence.
3270 """
3271 if len(candidates) == 0:
3272 return []
3273 elif len(candidates) > 1:
3274 log('[0] <all>')
3275 for i in range(0, len(candidates)):
3276 log('[{0}] {1}'.format(i + 1, candidates[i]))
3277 s = raw_input('Enter number of selection: ')
3278 try:
3279 si = int(s)
3280 except:
3281 si = 0
3282 if si == 0 or si not in range(1, len(candidates) + 1):
3283 return candidates
3284 else:
3285 return [candidates[si - 1]]
3286
3267 def javap(args): 3287 def javap(args):
3268 """disassemble classes matching given pattern with javap""" 3288 """disassemble classes matching given pattern with javap"""
3269 3289
3270 javap = java().javap 3290 javap = java().javap
3271 if not exists(javap): 3291 if not exists(javap):
3272 abort('The javap executable does not exists: ' + javap) 3292 abort('The javap executable does not exists: ' + javap)
3273 else: 3293 else:
3274 run([javap, '-private', '-verbose', '-classpath', classpath()] + findclass(args, logToConsole=False)) 3294 candidates = findclass(args, logToConsole=False)
3295 if len(candidates) == 0:
3296 log('no matches')
3297 selection = select_items(candidates)
3298 run([javap, '-private', '-verbose', '-classpath', classpath()] + selection)
3275 3299
3276 def show_projects(args): 3300 def show_projects(args):
3277 """show all loaded projects""" 3301 """show all loaded projects"""
3278 for s in suites(): 3302 for s in suites():
3279 projectsFile = join(s.dir, 'mx', 'projects') 3303 projectsFile = join(s.dir, 'mx', 'projects')