diff options
| -rwxr-xr-x | bin/mmsitepass | 35 | ||||
| -rwxr-xr-x | bin/newlist | 33 |
2 files changed, 53 insertions, 15 deletions
diff --git a/bin/mmsitepass b/bin/mmsitepass index eace10989..27dab419d 100755 --- a/bin/mmsitepass +++ b/bin/mmsitepass @@ -22,26 +22,47 @@ The site password can be used in most if not all places that the list administrator's password can be used, which in turn can be used in most places that a list users password can be used. -Usage: mmsitepass [password] +Usage: %(PROGRAM)s [options] [password] -If password is not given on the command line, it will be prompted for. +Options: + + -h/--help + Print this help message and exit. +If password is not given on the command line, it will be prompted for. """ import sys import getpass +import getopt import paths from Mailman import Utils +PROGRAM = sys.argv[0] + + + +def usage(code, msg=''): + print __doc__ % globals() + if msg: + print msg + sys.exit(code) + def main(): - if len(sys.argv) > 2: - print __doc__ - sys.exit(1) - elif len(sys.argv) == 2: - pw1 = sys.argv[1] + try: + opts, args = getopt.getopt(sys.argv[1:], 'h', ['help']) + except getopt.error, msg: + usage(1, msg) + + for opt, arg in opts: + if opt in ('-h', '--help'): + usage(0) + + if len(args) == 1: + pw1 = args[0] else: try: pw1 = getpass.getpass("New Password: ") diff --git a/bin/newlist b/bin/newlist index 277f1c814..e33654dd2 100755 --- a/bin/newlist +++ b/bin/newlist @@ -18,7 +18,12 @@ """Create a new, unpopulated mailing list. - newlist <list-name> <list-admin's-address> <admin-password> <immediate> +Usage: %(PROGRAM)s <listname> <listadmin's-addr> <admin-password> <immediate> + +Options: + + -h/--help + Print this help text and exit. You can specify as many of the arguments as you want on the command line. The optional <immediate> argument, if present, means to send out the notice @@ -26,7 +31,7 @@ immediately. Otherwise, the script hangs pending input, to give time for the person creating the list to customize it before sending the admin an email notice about the existence of the new list. -Note that list-names are forced to lowercase. +Note that listnames are forced to lowercase. """ import sys @@ -34,6 +39,7 @@ import os import string import time import getpass +import getopt import paths from Mailman import mm_cfg @@ -44,6 +50,7 @@ from Mailman import Message from Mailman.Handlers import HandlerAPI from Mailman.Crypt import crypt +PROGRAM = sys.argv[0] SENDMAIL_ALIAS_TEMPLATE = ''' Entry for aliases file: @@ -101,8 +108,17 @@ def usage(code, msg=''): def main(argv): - if len(argv) > 1: - listname = argv[1] + try: + opts, args = getopt.getopt(sys.argv[1:], 'h', ['help']) + except getopt.error, msg: + usage(1, msg) + + for opt, arg in opts: + if opt in ('-h', '--help'): + usage(0) + + if len(args) > 0: + listname = argv[0] else: listname = raw_input("Enter the name of the list: ") listname = string.lower(listname) @@ -113,13 +129,14 @@ def main(argv): if Utils.list_exists(listname): usage(1, 'List already exists: ' + listname) - if len(argv) > 2: - owner_mail = argv[2] + if len(args) > 1: + owner_mail = argv[1] else: owner_mail = raw_input( "Enter the email of the person running the list: ") - if len(argv) > 3: - list_pw = argv[3] + + if len(args) > 2: + list_pw = argv[2] else: list_pw = getpass.getpass("Initial %s password: " % listname) # List passwords cannot be empty |
