# HG changeset patch # User Jeff Hammel # Date 1294364980 28800 # Node ID 30100690ad3f54c2504b884326e786d3054bba86 # Parent 57f9b0349192ae712e006a87ea1a00b1da45fecb display defaults with command line --help option diff -r 57f9b0349192 -r 30100690ad3f makeitso/cli.py --- 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): diff -r 57f9b0349192 -r 30100690ad3f makeitso/template.py --- 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"""