comparison mxtool/mx.py @ 5824:b1dc8fbebb48

mx now handles unambiguous command prefixes (e.g. instead of 'mx eclipseinit' you can use 'mx ec')
author Doug Simon <doug.simon@oracle.com>
date Fri, 13 Jul 2012 09:06:14 +0200
parents 0cd337450409
children 767312416f6a
comparison
equal deleted inserted replaced
5823:f238fe91dc7f 5824:b1dc8fbebb48
2418 2418
2419 command = commandAndArgs[0] 2419 command = commandAndArgs[0]
2420 command_args = commandAndArgs[1:] 2420 command_args = commandAndArgs[1:]
2421 2421
2422 if not commands.has_key(command): 2422 if not commands.has_key(command):
2423 abort('mx: unknown command \'{0}\'\n{1}use "mx help" for more options'.format(command, _format_commands())) 2423 hits = [c for c in commands.iterkeys() if c.startswith(command)]
2424 if len(hits) == 1:
2425 command = hits[0]
2426 elif len(hits) == 0:
2427 abort('mx: unknown command \'{0}\'\n{1}use "mx help" for more options'.format(command, _format_commands()))
2428 else:
2429 abort('mx: command \'{0}\' is ambiguous\n {1}'.format(command, ' '.join(hits)))
2424 2430
2425 c, _ = commands[command][:2] 2431 c, _ = commands[command][:2]
2426 def term_handler(signum, frame): 2432 def term_handler(signum, frame):
2427 abort(1) 2433 abort(1)
2428 signal.signal(signal.SIGTERM, term_handler) 2434 signal.signal(signal.SIGTERM, term_handler)