aboutsummaryrefslogtreecommitdiffstats
path: root/fetchmailconf.py
diff options
context:
space:
mode:
Diffstat (limited to 'fetchmailconf.py')
-rwxr-xr-xfetchmailconf.py34
1 files changed, 24 insertions, 10 deletions
diff --git a/fetchmailconf.py b/fetchmailconf.py
index 8722d48a..909975d1 100755
--- a/fetchmailconf.py
+++ b/fetchmailconf.py
@@ -35,13 +35,26 @@ except:
# define a dummy class to inherit from
class Frame: pass
-VERSION = "1.63.4"
+VERSION = "1.63.5"
MIN_PY = (2, 7, 13)
if sys.version_info < MIN_PY:
sys.exit("fetchmailconf: Python %s.%s.%s or later is required.\n" % MIN_PY)
#
+# Display usage information and pass status argument through to sys.exit()
+#
+def usage(status):
+ print("""
+Usage: fetchmailconf {[-d] [-f fetchmailrc]|-h|--help|-V|--version}
+ -d - dump configuration (for debugging)
+ -f fmrc - read alternate fetchmailrc file
+--help, -h - print this help text and quit
+--version, -V - print fetchmailconf version and quit
+""")
+ sys.exit(status)
+
+#
# Define the data structures the GUIs will be tossing around
#
class Configuration(object):
@@ -2185,7 +2198,12 @@ gUSiYASJpMEHhilJTEnhAlGoQqYAZQ1AiqEMZ0jDGtqQImhwwA13yMMevoQAGvGhEAWHGMOAAAA7
#
# Process options
- options, arguments = getopt.getopt(sys.argv[1:], "df:hV", ["help", "version"])
+ try:
+ options, arguments = getopt.getopt(sys.argv[1:], "df:hV", ["help", "version"])
+ except getopt.GetoptError as e:
+ usage(str(e))
+ except Exception as e:
+ raise e
dump = rcfile = None
for (switch, val) in options:
if switch == '-d':
@@ -2193,14 +2211,7 @@ gUSiYASJpMEHhilJTEnhAlGoQqYAZQ1AiqEMZ0jDGtqQImhwwA13yMMevoQAGvGhEAWHGMOAAAA7
elif switch == '-f':
rcfile = val
elif switch == '-h' or switch == '--help':
- print("""
-Usage: fetchmailconf {[-d] [-f fetchmailrc]|-h|--help|-V|--version}
- -d - dump configuration (for debugging)
- -f fmrc - read alternate fetchmailrc file
---help, -h - print this help text and quit
---version, -V - print fetchmailconf version and quit
-""")
- sys.exit(0)
+ usage(0)
elif switch == '-V' or switch == '--version':
print("fetchmailconf %s" % VERSION)
print("Running on python", sys.version)
@@ -2212,6 +2223,9 @@ welcome to redistribute it under certain conditions. Please see the file
COPYING in the source or documentation directory for details.""")
sys.exit(0)
+ if arguments:
+ usage("Extra arguments: '" + "' '".join(arguments) + "'")
+
if "DISPLAY" not in os.environ:
sys.exit("fetchmailconf must be run under X")