From c0317c6817f3261a904376b6934d5e8deb69dda1 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Sat, 2 Apr 2011 22:09:43 +0200 Subject: [PATCH] Clean command-line options management --- radicale.py | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/radicale.py b/radicale.py index 79d32a9..bbc386f 100755 --- a/radicale.py +++ b/radicale.py @@ -26,10 +26,9 @@ # pylint: disable-msg=W0406 """ -Radicale Server entry point. +Radicale CalDAV Server. -Launch the Radicale Server according to configuration and command-line -arguments. +Launch the server according to configuration and command-line options. """ @@ -44,11 +43,7 @@ import threading import radicale # Get command-line options -parser = optparse.OptionParser() -parser.add_option( - "-v", "--version", action="store_true", - default=False, - help="show version and exit") +parser = optparse.OptionParser(version=radicale.VERSION) parser.add_option( "-d", "--daemon", action="store_true", default=radicale.config.getboolean("server", "daemon"), @@ -59,7 +54,7 @@ parser.add_option( parser.add_option( "-H", "--hosts", default=radicale.config.get("server", "hosts"), - help="set server hostnames") + help="set server hostnames and ports") parser.add_option( "-s", "--ssl", action="store_true", default=radicale.config.getboolean("server", "ssl"), @@ -70,11 +65,11 @@ parser.add_option( parser.add_option( "-k", "--key", default=radicale.config.get("server", "key"), - help="private key file ") + help="set private key file") parser.add_option( "-c", "--certificate", default=radicale.config.get("server", "certificate"), - help="certificate file ") + help="set certificate file") options = parser.parse_args()[0] # Update Radicale configuration according to options @@ -84,11 +79,6 @@ for option in parser.option_list: value = getattr(options, key) radicale.config.set("server", key, value) -# Print version and exit if the option is given -if options.version: - print(radicale.VERSION) - sys.exit() - # Fork if Radicale is launched as daemon if options.daemon: if os.fork():