Skip to content

Commit

Permalink
Clean command-line options management
Browse files Browse the repository at this point in the history
  • Loading branch information
liZe committed Apr 2, 2011
1 parent 48be062 commit c0317c6
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions radicale.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""

Expand All @@ -44,11 +43,7 @@
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"),
Expand All @@ -59,7 +54,7 @@
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"),
Expand All @@ -70,11 +65,11 @@
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
Expand All @@ -84,11 +79,6 @@
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():
Expand Down

0 comments on commit c0317c6

Please sign in to comment.