Mercurial > hg > graal-jvmci-8
comparison mxtool/mx.py @ 21998:416e4e9d70fa
mxtool: add support for -y/-n (answer 'y'/'n' to all question).
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Wed, 17 Jun 2015 13:22:40 +0200 |
parents | c0b6865b7698 |
children | f2cf8824040b |
comparison
equal
deleted
inserted
replaced
21997:5576d06db82a | 21998:416e4e9d70fa |
---|---|
1720 ArgumentParser.__init__(self, prog='mx', conflict_handler='resolve') | 1720 ArgumentParser.__init__(self, prog='mx', conflict_handler='resolve') |
1721 | 1721 |
1722 self.add_argument('-v', action='store_true', dest='verbose', help='enable verbose output') | 1722 self.add_argument('-v', action='store_true', dest='verbose', help='enable verbose output') |
1723 self.add_argument('-V', action='store_true', dest='very_verbose', help='enable very verbose output') | 1723 self.add_argument('-V', action='store_true', dest='very_verbose', help='enable very verbose output') |
1724 self.add_argument('-w', action='store_true', dest='warn', help='enable warning messages') | 1724 self.add_argument('-w', action='store_true', dest='warn', help='enable warning messages') |
1725 self.add_argument('-y', action='store_const', const='y', dest='answer', help='answer \'y\' to all questions asked') | |
1726 self.add_argument('-n', action='store_const', const='n', dest='answer', help='answer \'n\' to all questions asked') | |
1725 self.add_argument('-p', '--primary-suite-path', help='set the primary suite directory', metavar='<path>') | 1727 self.add_argument('-p', '--primary-suite-path', help='set the primary suite directory', metavar='<path>') |
1726 self.add_argument('--dbg', type=int, dest='java_dbg_port', help='make Java processes wait on <port> for a debugger', metavar='<port>') | 1728 self.add_argument('--dbg', type=int, dest='java_dbg_port', help='make Java processes wait on <port> for a debugger', metavar='<port>') |
1727 self.add_argument('-d', action='store_const', const=8000, dest='java_dbg_port', help='alias for "-dbg 8000"') | 1729 self.add_argument('-d', action='store_const', const=8000, dest='java_dbg_port', help='alias for "-dbg 8000"') |
1728 self.add_argument('--backup-modified', action='store_true', help='backup generated files if they pre-existed and are modified') | 1730 self.add_argument('--backup-modified', action='store_true', help='backup generated files if they pre-existed and are modified') |
1729 self.add_argument('--cp-pfx', dest='cp_prefix', help='class path prefix', metavar='<arg>') | 1731 self.add_argument('--cp-pfx', dest='cp_prefix', help='class path prefix', metavar='<arg>') |
5612 else: | 5614 else: |
5613 abort("Can not answer '" + question + "?' if stdout is not a tty") | 5615 abort("Can not answer '" + question + "?' if stdout is not a tty") |
5614 questionMark = '? [yn]: ' | 5616 questionMark = '? [yn]: ' |
5615 if default: | 5617 if default: |
5616 questionMark = questionMark.replace(default, default.upper()) | 5618 questionMark = questionMark.replace(default, default.upper()) |
5617 answer = raw_input(question + questionMark) or default | 5619 if _opts.answer: |
5618 while not answer: | 5620 answer = str(_opts.answer) |
5619 answer = raw_input(question + questionMark) | 5621 print question + questionMark + answer |
5622 else: | |
5623 answer = raw_input(question + questionMark) or default | |
5624 while not answer: | |
5625 answer = raw_input(question + questionMark) | |
5620 return answer.lower().startswith('y') | 5626 return answer.lower().startswith('y') |
5621 | 5627 |
5622 def add_argument(*args, **kwargs): | 5628 def add_argument(*args, **kwargs): |
5623 """ | 5629 """ |
5624 Define how a single command-line argument. | 5630 Define how a single command-line argument. |