summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbwarsaw1999-11-12 17:39:17 +0000
committerbwarsaw1999-11-12 17:39:17 +0000
commit00ea7fee9b053cb9a4cdf8b337032a3c09be9288 (patch)
treeb40e6f833222570083f3daed4f34ddc9b3685466
parent9936a3553dedaa0c072f10cbbb614c5815d830e9 (diff)
downloadmailman-00ea7fee9b053cb9a4cdf8b337032a3c09be9288.tar.gz
mailman-00ea7fee9b053cb9a4cdf8b337032a3c09be9288.tar.zst
mailman-00ea7fee9b053cb9a4cdf8b337032a3c09be9288.zip
Standardized argument parsing
-rw-r--r--bin/move_list31
1 files changed, 29 insertions, 2 deletions
diff --git a/bin/move_list b/bin/move_list
index 9d21099f2..1b152bbff 100644
--- a/bin/move_list
+++ b/bin/move_list
@@ -23,12 +23,21 @@ public_archive_file_dir, private_archive_file_dir, and archive_directory by
recalculating them based on the new Defaults. It then saves the list.
Usage:
- move_list listname
+ move_list [options] listname
+
+Options:
+ --help
+ -h
+ Print this help message and exit.
+
+listname must be a valid mailing list name and is required.
"""
import os
import sys
+import getopt
+
import paths
from Mailman import MailList
from Mailman import mm_cfg
@@ -45,9 +54,27 @@ def usage(code, msg=''):
def main():
try:
- mlist = MailList.MailList(sys.argv[1])
+ 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:
+ usage(1)
+
+ try:
+ listname = args[0]
except IndexError:
usage(1, 'You must supply a list name.')
+
+ try:
+ mlist = MailList.MailList(listname)
+ except Errors.MMUnknownListError:
+ usage(1, 'List not found: ' + listname)
+
try:
mlist.public_archive_file_dir = mm_cfg.PUBLIC_ARCHIVE_FILE_DIR
mlist.private_archive_file_dir = os.path.join(