-# XXX Python's getopt does not support options with optional arguments, so we
-# have to separate --pidfile (with no argument) from --pidfile-name (with an
-# argument). Need to write our own getopt I guess.
-LONG_OPTIONS = ["detach", "no-chdir", "pidfile", "pidfile-name=",
- "overwrite-pidfile", "monitor"]
+
+def add_args(parser):
+ """Populates 'parser', an ArgumentParser allocated using the argparse
+ module, with the command line arguments required by the daemon module."""
+
+ pidfile = make_pidfile_name(None)
+
+ group = parser.add_argument_group(title="Daemon Options")
+ group.add_argument("--detach", action="store_true",
+ help="Run in background as a daemon.")
+ group.add_argument("--no-chdir", action="store_true",
+ help="Do not chdir to '/'.")
+ group.add_argument("--monitor", action="store_true",
+ help="Monitor %s process." % ovs.util.PROGRAM_NAME)
+ group.add_argument("--pidfile", nargs="?", const=pidfile,
+ help="Create pidfile (default %s)." % pidfile)
+ group.add_argument("--overwrite-pidfile", action="store_true",
+ help="With --pidfile, start even if already running.")