1616# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1717# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1818#
19- # $Id: roundup-admin,v 1.27 2001-10-11 23:43:04 richard Exp $
19+ # $Id: roundup-admin,v 1.28 2001-10-13 00:07:39 richard Exp $
2020
2121import sys
2222if int (sys .version [0 ]) < 2 :
@@ -33,28 +33,29 @@ import roundup.instance
3333
3434def usage (message = '' ):
3535 if message : message = 'Problem: ' + message + '\n '
36- commands = []
37- for command in figureCommands ().values ():
38- h = command .__doc__ .split ('\n ' )[0 ]
39- commands .append (h [7 :])
40- commands .sort ()
4136 print '''%sUsage: roundup-admin [-i instance home] [-u login] [-c] <command> <arguments>
4237
43- Commands:
44- %s
4538Help:
4639 roundup-admin -h
4740 roundup-admin help -- this help
4841 roundup-admin help <command> -- command-specific help
49- roundup-admin morehelp -- even more detailed help
42+ roundup-admin help all -- all available help
5043Options:
5144 -i instance home -- specify the issue tracker "home directory" to administer
5245 -u -- the user[:password] to use for commands
53- -c -- when outputting lists of data, just comma-separate them''' % (
54- message , '\n ' .join (commands ))
46+ -c -- when outputting lists of data, just comma-separate them''' % message
47+ help_commands ()
48+
49+ def help_commands ():
50+ print 'Commands:' ,
51+ commands = ['' ]
52+ for command in figureCommands ().values ():
53+ h = command .__doc__ .split ('\n ' )[0 ]
54+ commands .append (h [7 :])
55+ commands .sort ()
56+ print '\n ' .join (commands )
5557
56- def moreusage (message = '' ):
57- usage (message )
58+ def help_all ():
5859 print '''
5960All commands (except help) require an instance specifier. This is just the path
6061to the roundup instance you're working with. A roundup instance is where
@@ -108,13 +109,41 @@ Command help:
108109 print '%s:' % name
109110 print ' ' ,command .__doc__
110111
112+ def do_help (args ):
113+ '''Usage: help topic
114+ Give help about topic.
115+
116+ commands -- list commands
117+ <command> -- help specific to a command
118+ initopts -- init command options
119+ all -- all available help
120+ '''
121+ help = figureHelp ().get (args [0 ], None )
122+ if help :
123+ help ()
124+ return
125+ help = figureCommands ().get (args [0 ], None )
126+ if help :
127+ print help .__doc__
128+
129+ def help_initopts ():
130+ import roundup .templates
131+ templates = roundup .templates .listTemplates ()
132+ print 'Templates:' , ', ' .join (templates )
133+ import roundup .backends
134+ backends = roundup .backends .__all__
135+ print 'Back ends:' , ', ' .join (backends )
136+
137+
111138def do_init (instance_home , args , comma_sep = 0 ):
112139 '''Usage: init [template [backend [admin password]]]
113140 Initialise a new Roundup instance.
114141
115142 The command will prompt for the instance home directory (if not supplied
116143 through INSTANCE_HOME or the -i option. The template, backend and admin
117144 password may be specified on the command-line as arguments, in that order.
145+
146+ See also initopts help.
118147 '''
119148 # select template
120149 import roundup .templates
@@ -485,13 +514,12 @@ def figureCommands():
485514 d [k [3 :]] = v
486515 return d
487516
488- def printInitOptions ():
489- import roundup .templates
490- templates = roundup .templates .listTemplates ()
491- print 'Templates:' , ', ' .join (templates )
492- import roundup .backends
493- backends = roundup .backends .__all__
494- print 'Back ends:' , ', ' .join (backends )
517+ def figureHelp ():
518+ d = {}
519+ for k , v in globals ().items ():
520+ if k [:5 ] == 'help_' :
521+ d [k [5 :]] = v
522+ return d
495523
496524def main ():
497525 opts , args = getopt .getopt (sys .argv [1 :], 'i:u:hc' )
@@ -507,8 +535,8 @@ def main():
507535 comma_sep = 0
508536 for opt , arg in opts :
509537 if opt == '-h' :
510- usage ()
511- return 0
538+ args = [ 'help' ]
539+ break
512540 if opt == '-i' :
513541 instance_home = arg
514542 if opt == '-c' :
@@ -523,18 +551,13 @@ def main():
523551 # handle help now
524552 if command == 'help' :
525553 if len (args )> 1 :
526- command = figureCommands ().get (args [1 ], None )
527- if not command :
528- usage ('no such command "%s"' % args [1 ])
529- return 1
530- print command .__doc__
531- if args [1 ] == 'init' :
532- printInitOptions ()
554+ do_help (args [1 :])
533555 return 0
534556 usage ()
535557 return 0
536558 if command == 'morehelp' :
537- moreusage ()
559+ usage ()
560+ help_all ()
538561 return 0
539562
540563 # make sure we have an instance_home
@@ -574,6 +597,10 @@ if __name__ == '__main__':
574597
575598#
576599# $Log: not supported by cvs2svn $
600+ # Revision 1.27 2001/10/11 23:43:04 richard
601+ # Implemented the comma-separated printing option in the admin tool.
602+ # Fixed a typo (more of a vim-o actually :) in mailgw.
603+ #
577604# Revision 1.26 2001/10/11 05:03:51 richard
578605# Marked the roundup-admin import/export as experimental since they're not fully
579606# operational.
0 commit comments