Mercurial > hg > MakeItSo
changeset 62:30100690ad3f
display defaults with command line --help option
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Thu, 06 Jan 2011 17:49:40 -0800 |
parents | 57f9b0349192 |
children | b91133e3b02d |
files | makeitso/cli.py makeitso/template.py |
diffstat | 2 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/makeitso/cli.py Thu Jan 06 17:14:22 2011 -0800 +++ b/makeitso/cli.py Thu Jan 06 17:49:40 2011 -0800 @@ -2,6 +2,7 @@ command line parser for MakeItSo """ +from template import Undefined from optparse import OptionParser class MakeItSoCLI(object): @@ -20,9 +21,12 @@ # add the variables as options for variable in self.template_class.vars: + description = variable.description + if (variable.default is not None) and (variable.default is not Undefined): + description += ' [DEFAULT: %s]' % variable.default parser.add_option('--%s' % variable.name, dest=variable.name, default=variable.default, - help=variable.description) + help=description) return parser def parse(self):
--- a/makeitso/template.py Thu Jan 06 17:14:22 2011 -0800 +++ b/makeitso/template.py Thu Jan 06 17:49:40 2011 -0800 @@ -9,6 +9,8 @@ class Undefined(object): """marker class for variables""" + def __int__(self): + return 0 Undefined = Undefined() # singleton class Variable(object): @@ -93,11 +95,15 @@ assert os.path.exists(template) def missing(self, **variables): + missing = set([]) if self.look: pass else: - if self.usedefaults: - pass + for var in self.vars: + if self.usedefaults: + pass + else: + pass def pre(self, **variables): """do stuff before interpolation"""