From: richard Date: Wed, 17 Oct 2001 06:04:00 +0000 (+0000) Subject: Beginnings of an interactive mode for roundup-admin X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=87153e2ad1fbae49052e4f03af56b4acadfa3bd7;p=roundup.git Beginnings of an interactive mode for roundup-admin git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@306 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/roundup-admin b/roundup-admin index d3b5d65..befa0a2 100755 --- a/roundup-admin +++ b/roundup-admin @@ -16,7 +16,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: roundup-admin,v 1.29 2001-10-16 03:48:01 richard Exp $ +# $Id: roundup-admin,v 1.30 2001-10-17 06:04:00 richard Exp $ import sys if int(sys.version[0]) < 2: @@ -125,6 +125,8 @@ def do_help(args): help = figureCommands().get(args[0], None) if help: print help.__doc__ + else: + print 'Sorry, no help for "%s"'%args[0] def help_initopts(): import roundup.templates @@ -525,82 +527,106 @@ def figureHelp(): d[k[5:]] = v return d -def main(): - opts, args = getopt.getopt(sys.argv[1:], 'i:u:hc') - - # handle command-line args - instance_home = os.environ.get('ROUNDUP_INSTANCE', '') - name = password = '' - if os.environ.has_key('ROUNDUP_LOGIN'): - l = os.environ['ROUNDUP_LOGIN'].split(':') - name = l[0] - if len(l) > 1: - password = l[1] - comma_sep = 0 - for opt, arg in opts: - if opt == '-h': - args = ['help'] - break - if opt == '-i': - instance_home = arg - if opt == '-c': - comma_sep = 1 - - # figure the command - if not args: - usage('No command specified') - return 1 - command = args[0] +class AdminTool: + + def run_command(self, args): + command = args[0] - # handle help now - if command == 'help': - if len(args)>1: - do_help(args[1:]) + # handle help now + if command == 'help': + if len(args)>1: + do_help(args[1:]) + return 0 + do_help(['help']) + return 0 + if command == 'morehelp': + do_help(['help']) + help_commands() + help_all() return 0 - usage() - return 0 - if command == 'morehelp': - usage() - help_all() - return 0 - - # make sure we have an instance_home - while not instance_home: - instance_home = raw_input('Enter instance home: ').strip() - - # before we open the db, we may be doing an init - if command == 'init': - return do_init(instance_home, args) - - function = figureCommands().get(command, None) - - # not a valid command - if function is None: - usage('Unknown command "%s"'%command) - return 1 - # get the instance - instance = roundup.instance.open(instance_home) - db = instance.open('admin') + # make sure we have an instance_home + while not self.instance_home: + self.instance_home = raw_input('Enter instance home: ').strip() - if len(args) < 2: - print function.__doc__ - return 1 + # before we open the db, we may be doing an init + if command == 'init': + return do_init(self.instance_home, args) - # do the command - try: - return function(db, args[1:], comma_sep=comma_sep) - finally: - db.close() + function = figureCommands().get(command, None) - return 1 + # not a valid command + if function is None: + usage('Unknown command "%s"'%command) + return 1 + + # get the instance + instance = roundup.instance.open(self.instance_home) + db = instance.open('admin') + + if len(args) < 2: + print function.__doc__ + return 1 + + # do the command + try: + return function(db, args[1:], comma_sep=self.comma_sep) + finally: + db.close() + + return 1 + + def interactive(self, ws_re=re.compile(r'\s+')): + '''Run in an interactive mode + ''' + while 1: + try: + command = raw_input('roundup> ') + except EOFError: + print '.. exit' + return 0 + args = ws_re.split(command) + if not args: continue + if args[0] in ('quit', 'exit'): return 0 + self.run_command(args) + + def main(self): + opts, args = getopt.getopt(sys.argv[1:], 'i:u:hc') + + # handle command-line args + self.instance_home = os.environ.get('ROUNDUP_INSTANCE', '') + name = password = '' + if os.environ.has_key('ROUNDUP_LOGIN'): + l = os.environ['ROUNDUP_LOGIN'].split(':') + name = l[0] + if len(l) > 1: + password = l[1] + self.comma_sep = 0 + for opt, arg in opts: + if opt == '-h': + usage() + return 0 + if opt == '-i': + self.instance_home = arg + if opt == '-c': + self.comma_sep = 1 + + # if no command - go interactive + if not args: + return self.interactive() + + self.run_command(args) if __name__ == '__main__': - sys.exit(main()) + tool = AdminTool() + sys.exit(tool.main()) # # $Log: not supported by cvs2svn $ +# Revision 1.29 2001/10/16 03:48:01 richard +# admin tool now complains if a "find" is attempted with a non-link property. +# # Revision 1.28 2001/10/13 00:07:39 richard # More help in admin tool. # diff --git a/setup.py b/setup.py index f4cf3ef..68f1074 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: setup.py,v 1.22 2001-10-11 05:01:28 richard Exp $ +# $Id: setup.py,v 1.23 2001-10-17 06:04:00 richard Exp $ from distutils.core import setup, Extension from distutils.util import get_platform @@ -42,7 +42,7 @@ for t in templates: setup ( name = "roundup", - version = "0.3.0pre2", + version = "0.3.0pre3", description = "Roundup issue tracking system.", author = "Richard Jones", author_email = "richard@users.sourceforge.net", @@ -53,6 +53,9 @@ setup ( name = "roundup", # # $Log: not supported by cvs2svn $ +# Revision 1.22 2001/10/11 05:01:28 richard +# Prep for pre-release #2 +# # Revision 1.21 2001/10/10 04:18:38 richard # Getting ready for a preview release for 0.3.0. #