Mercurial > hg > configuration
comparison configuration/configuration.py @ 89:0804a706d6bf
handle CLI errors with optparse
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sat, 28 Apr 2012 15:29:57 -0700 |
parents | 36cf1d9bf40b |
children | 6bf4a58b0988 |
comparison
equal
deleted
inserted
replaced
88:36cf1d9bf40b | 89:0804a706d6bf |
---|---|
400 missingvalues = None | 400 missingvalues = None |
401 try: | 401 try: |
402 # generate configuration | 402 # generate configuration |
403 self(*config) | 403 self(*config) |
404 except MissingValueException, missingvalues: | 404 except MissingValueException, missingvalues: |
405 # errors are handled below | |
405 pass | 406 pass |
406 | 407 |
407 # dump configuration, if specified | 408 # dump configuration, if specified |
408 dump = getattr(options, 'dump') | 409 dump = getattr(options, 'dump') |
409 if dump: | 410 if dump: |
410 # TODO: have a way of specifying format other than filename | 411 # TODO: have a way of specifying format other than filename |
411 self.serialize(dump) | 412 self.serialize(dump) |
412 | 413 |
413 if missingvalues and not dump: | 414 if missingvalues and not dump: |
414 # XXX assuming if you don't have values you were just dumping | 415 # XXX assuming if you don't have values you were just dumping |
415 raise missingvalues | 416 self.error(str(missingvalues)) |
416 | 417 |
417 # update options from config | 418 # update options from config |
418 options.__dict__.update(self.config) | 419 options.__dict__.update(self.config) |
419 | 420 |
420 # return parsed arguments | 421 # return parsed arguments |