From 57b3324eff49b79b246589d2d1e87f6413f924e3 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sat, 21 Jun 2008 13:19:05 +0200 Subject: New cmd option parsing --- nbb/nbb_lib.in | 54 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/nbb/nbb_lib.in b/nbb/nbb_lib.in index cedc1e5..45089ea 100644 --- a/nbb/nbb_lib.in +++ b/nbb/nbb_lib.in @@ -365,11 +365,20 @@ class AutomakeSourceTree(BSSourceTree): ######################################################################## -# Main program +# Commands ######################################################################## -class NBB(object): - def __init__(self, srcdir=None): +class NBB_Command(object): + def __init__(self, cmd, cmdargs): + print "Command:", cmd + print "Cmd arg:", cmdargs + if cmd in ('help', ): + print "List of commands:" + raise NotImplementedError() + else: + print "Fatal: Unknown command '%s'" % cmd + raise NotImplementedError() + srcdir = None if srcdir is None: srcdir = os.getcwd() absdir = os.path.abspath(srcdir) @@ -388,6 +397,10 @@ class NBB(object): print "Program aborted." +######################################################################## +# Main program +######################################################################## + def main(argv): prog = argv[0] @@ -395,32 +408,31 @@ def main(argv): if idx >= 0: prog = prog[idx+1:] -# print """\ -#WARNING: %(prog)s is very much a work in progress. -# Large parts of %(prog)s are not implemented yet. -#""" % locals() - # FIXME: Generate from plugin systems. buildsystems = ', '.join(['automake', ]) vcssystems = ', '.join(['bzr', 'git', ]) - optlist, args = getopt.getopt(argv[1:], 'hV', ['help', 'version']) - for opt, arg in optlist: - if opt in ('-h', '--help'): + print "argv:", `argv` + verbosity = 0 + i = 1 + while i