summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Ulrich Niedermann <hun@n-dimensional.de>2008-06-21 14:44:59 +0200
committerHans Ulrich Niedermann <hun@n-dimensional.de>2008-06-21 14:45:09 +0200
commit56e237fae61ac215278d385b40bae576ae6a919a (patch)
treed15304c00747a7030f6b19d923dc8ced2f5cc86e
parent68ebec8103f62b2cd5479a485989db3520e1e52c (diff)
More messing with basic nbb commands and tests
-rw-r--r--nbb/nbb_lib.in36
-rw-r--r--test/nbb.at24
2 files changed, 45 insertions, 15 deletions
diff --git a/nbb/nbb_lib.in b/nbb/nbb_lib.in
index 955ca1a..5f5200b 100644
--- a/nbb/nbb_lib.in
+++ b/nbb/nbb_lib.in
@@ -294,7 +294,9 @@ class Command(object):
def validate_args(self, *args, **kwargs):
"""Validate command line arguments"""
- pass
+ print "Command: ", self.name
+ print "*args: ", args
+ print "**kwargs:", kwargs
def __str__(self):
return "Command(%s, %s)" % (self.cmd_name, self.cmdargs)
@@ -302,7 +304,7 @@ class Command(object):
class HelpCommand(Command):
name = 'help'
- summary = 'Print help text'
+ summary = 'print help text'
def run(self):
print "List of commands:"
keys = Command.plugins.keys()
@@ -310,14 +312,24 @@ class HelpCommand(Command):
for k in keys:
print "\t%-15s\t%s" % (k, Command.plugins[k].summary)
+class InternalConfigCommand(Command):
+ name = 'internal-config'
+ summary = 'print internal program configuration'
+ def run(self):
+ print "Source tree types:", ", ".join([ x.vcs_name for x in VCSourceTree.plugins ])
+ print "Build system types:", ", ".join([ x.bs_name for x in BSSourceTree.plugins ])
+ print "Commands:", ", ".join(Command.plugins.keys())
+
class ClassCommand(Command):
pass
class FooCommand(ClassCommand):
name = 'foo'
+ summary = 'bogus command for testing the command infrastructure'
class BarCommand(ClassCommand):
name = 'bar'
+ summary = 'bogus command for testing the command infrastructure'
########################################################################
@@ -478,8 +490,6 @@ class AutomakeSourceTree(BSSourceTree):
class NBB_Command(object):
def __init__(self, cmd, cmdargs):
- print "Command:", cmd
- print "Cmd arg:", cmdargs
if Command.plugins.has_key(cmd):
c = Command.plugins[cmd](*cmdargs)
c.run()
@@ -509,6 +519,13 @@ class NBB_Command(object):
# Main program
########################################################################
+
+def print_help():
+ vcssystems = ", ".join([ x.vcs_name for x in VCSourceTree.plugins ])
+ buildsystems = ", ".join([ x.bs_name for x in BSSourceTree.plugins ])
+ print __doc__ % locals()
+
+
def main(argv):
prog = argv[0]
@@ -516,18 +533,17 @@ def main(argv):
if idx >= 0:
prog = prog[idx+1:]
- print "argv:", `argv`
- print "Source tree plugins:", ", ".join([ x.vcs_name for x in VCSourceTree.plugins ])
- print "Build system plugins:", ", ".join([ x.bs_name for x in BSSourceTree.plugins ])
- print "Command plugins:", ", ".join(Command.plugins.keys())
- print "Command plugins:", Command.plugins
+ if len(argv) < 2:
+ print "Fatal: %(prog)s requires some arguments" % locals()
+ return 2
+
verbosity = 0
i = 1
while i<len(argv):
if argv[i][0] != '-':
break
if argv[i] in ('-h', '--help'):
- print __doc__ % locals()
+ print_help()
return
elif argv[i] in ('-V', '--version'):
print "%(prog)s (@PACKAGE_NAME@) @PACKAGE_VERSION@" % locals()
diff --git a/test/nbb.at b/test/nbb.at
index 5e7e849..b632f32 100644
--- a/test/nbb.at
+++ b/test/nbb.at
@@ -7,9 +7,9 @@ dnl ===================================================================
dnl ===================================================================
-AT_SETUP([nbb --version])
+AT_SETUP([nbb: --version option])
AT_KEYWORDS([nbb version])
-AT_CHECK([nbb --version | grep ^nbb],
+AT_CHECK([nbb --version],
[0],
[nbb (ndims git utilities) AT_PACKAGE_VERSION
])
@@ -17,14 +17,28 @@ AT_CLEANUP()
dnl ===================================================================
-AT_SETUP([nbb --help])
+AT_SETUP([nbb: --help option])
AT_KEYWORDS([nbb help])
AT_CHECK([nbb --help], [0], [ignore], [ignore])
AT_CLEANUP()
dnl ===================================================================
-AT_SETUP([nbb git config default defaults])
+AT_SETUP([nbb: help command])
+AT_KEYWORDS([nbb help])
+AT_CHECK([nbb help], [0], [ignore], [])
+AT_CLEANUP()
+
+dnl ===================================================================
+
+AT_SETUP([nbb: internal-config command])
+AT_KEYWORDS([nbb internal-config])
+AT_CHECK([nbb internal-config], [0], [ignore], [])
+AT_CLEANUP()
+
+dnl ===================================================================
+
+AT_SETUP([nbb: git config default defaults])
AT_KEYWORDS([nbb git config])
AT_CHECK([mkdir test.git && cd test.git])
AT_CHECK([cd test.git && git init], [0],
@@ -41,7 +55,7 @@ AT_CLEANUP()
dnl ===================================================================
-AT_SETUP([nbb bzr config defaults])
+AT_SETUP([nbb: bzr config defaults])
AT_KEYWORDS([nbb bzr config])
AT_CHECK([mkdir test.bzr && cd test.bzr])
AT_CHECK([cd test.bzr && bzr init])