From 0cade220495ffcdef8e661557efca318b81dcfe3 Mon Sep 17 00:00:00 2001 From: David Bartley Date: Fri, 28 Mar 2008 15:46:32 -0400 Subject: [PATCH] Add help for command-line ceo --- ceo/console/expiredaccounts.py | 7 +++++++ ceo/console/inactive.py | 8 +++++++- ceo/console/main.py | 23 +++++++++++++++++++---- ceo/console/memberlist.py | 12 +++++++++++- ceo/console/updateprograms.py | 5 +++++ 5 files changed, 49 insertions(+), 6 deletions(-) diff --git a/ceo/console/expiredaccounts.py b/ceo/console/expiredaccounts.py index cb108fc..49d3ad5 100644 --- a/ceo/console/expiredaccounts.py +++ b/ceo/console/expiredaccounts.py @@ -2,6 +2,13 @@ import ldap from ceo import members, uwldap class ExpiredAccounts: + help = ''' +expiredaccounts [--email] + +Displays a list of expired accounts. If --email is specified, expired account +owners will be emailed. The email will go to the email listed in uwdir. +''' + def main(self, args): send_email = False if len(args) == 1 and args[0] == '--email': diff --git a/ceo/console/inactive.py b/ceo/console/inactive.py index 320d6c3..bb3c89b 100644 --- a/ceo/console/inactive.py +++ b/ceo/console/inactive.py @@ -7,9 +7,15 @@ def max_term(term1, term2): return term2 class Inactive: + help = ''' +inactive delta-terms + +Prints a list of accounts that have been inactive (i.e. not unpaid) for +delta-terms. +''' def main(self, args): if len(args) != 1: - print "Usage: ceo inactive delta-terms" + print self.help return delta = int(args[0]) mlist = members.list_all() diff --git a/ceo/console/main.py b/ceo/console/main.py index e375345..1156f53 100644 --- a/ceo/console/main.py +++ b/ceo/console/main.py @@ -24,11 +24,26 @@ def start(): (opts, args) = getopt(sys.argv[1:], shortopts, longopts) if len(args) >= 1: if args[0] in commands: - commands[args[0]].main(args[1:]) + command = commands[args[0]] + if len(args) >= 2 and args[1] in ['--help', '-h']: + print command.help + else: + command.main(args[1:]) else: print "Invalid command '%s'" % args[0] def help(): - print 'Available commands:' - for c in commands: - print ' %s' % c + args = sys.argv[2:] + if len(args) == 1: + if args[0] in commands: + print commands[args[0]].help + else: + print 'Unknown command %s.' % args[0] + else: + print '' + print 'Available commands:' + for c in commands: + print ' %s' % c + print '' + print 'Run \'ceo command --help\' for help on a specific command.' + print '' diff --git a/ceo/console/memberlist.py b/ceo/console/memberlist.py index 428278e..10237ad 100644 --- a/ceo/console/memberlist.py +++ b/ceo/console/memberlist.py @@ -1,8 +1,18 @@ from ceo import members, terms class MemberList: + help = ''' +memberlist [term] + +Displays a list of members for a term; defaults to the current term if term +is not given. +''' def main(self, args): - mlist = members.list_term(terms.current()) + mlist = {} + if len(args) == 1: + mlist = members.list_term(args[0]) + else: + mlist = members.list_term(terms.current()) dns = mlist.keys() dns.sort() for dn in dns: diff --git a/ceo/console/updateprograms.py b/ceo/console/updateprograms.py index d38bd35..c4cc174 100644 --- a/ceo/console/updateprograms.py +++ b/ceo/console/updateprograms.py @@ -2,6 +2,11 @@ import ldap, sys, termios from ceo import members, uwldap, ldapi class UpdatePrograms: + help = ''' +updateprograms + +Interactively updates the program field for an account by querying uwdir. +''' def main(self, args): mlist = members.list_all().items() uwl = ldap.initialize(uwldap.uri())