X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FCommandLine.hs;h=adbb0d84c00493bcf2cffbfbbdb1f62cf702e329;hb=ac3a81eb6d0f8ca4e212752d5b390a4fc220cceb;hp=071c5209307116787404555eecfa941b22b1488a;hpb=a2c2a1a6865be7b4cd17fb72de635bb9385728b9;p=dead%2Fhtsn.git diff --git a/src/CommandLine.hs b/src/CommandLine.hs index 071c520..adbb0d8 100644 --- a/src/CommandLine.hs +++ b/src/CommandLine.hs @@ -6,6 +6,7 @@ where import System.Console.CmdArgs ( (&=), + args, cmdArgs, def, details, @@ -13,18 +14,18 @@ import System.Console.CmdArgs ( program, summary, typ, + typFile, typDir ) -- This let's us get the version from Cabal. import Paths_htsn (version) import Data.Version (showVersion) -import OptionalConfiguration (OptionalConfiguration(..)) - +import OptionalConfiguration ( OptionalConfiguration(..) ) -- | The description of the program, displayed as part of the help. description :: String -description = "Parse XML files from The Sports Network." +description = "Parse XML files from The Sports Network feed." -- | The name of this program. program_name :: String @@ -35,20 +36,55 @@ my_summary :: String my_summary = program_name ++ "-" ++ (showVersion version) --- | A description of the "password" option. -password_help :: String -password_help = - "Password to use when connecting to the feed" +-- | A description of the "daemonize" option. +daemonize_help :: String +daemonize_help = + "Run as a daemon, in the background." + +-- | A description of the "log_file" option. +log_file_help :: String +log_file_help = + "Log to the given file." + +-- | A description of the "log_level" option. +log_level_help :: String +log_level_help = + "How verbose should the logs be? One of INFO, WARNING, ERROR." -- | A description of the "output_directory" option. output_directory_help :: String output_directory_help = - "Directory in which to output the XML files; must be writable" + "Directory in which to output the XML files; must be writable." + +-- | A description of the "password" option. +password_help :: String +password_help = + "Password to use when connecting to the feed." + +-- | A description of the "pidfile" option. +pidfile_help :: String +pidfile_help = + "Location to create PID file (daemon only)." + +-- | A description of the "run_as_group" option. +run_as_group_help :: String +run_as_group_help = + "System group to run as (daemon only)." + +-- | A description of the "run_as_user" option. +run_as_user_help :: String +run_as_user_help = + "System user to run under (daemon only)." + +-- | A description of the "syslog" option. +syslog_help :: String +syslog_help = + "Enable logging to syslog." -- | A description of the "username" option. username_help :: String username_help = - "Username to use when connecting to the feed" + "Username to use when connecting to the feed." -- | A data structure representing the possible command-line -- options. The CmdArgs library is doing heavy magic beneath the @@ -56,10 +92,20 @@ username_help = arg_spec :: OptionalConfiguration arg_spec = OptionalConfiguration { - password = def &= typ "PASSWORD" &= help password_help, - output_directory = def &= typDir &= help output_directory_help, - username = def &= typ "USERNAME" &= help username_help, - feed_hosts = def &= typ "HOSTNAMES" } + -- Use an empty list for feed_hosts since cmdargs will appends to + -- the default when the user supplies feed hosts. If he specifies + -- any, those are all we should use. + daemonize = def &= typ "BOOL" &= help daemonize_help, + feed_hosts = def &= typ "HOSTNAMES" &= args, + log_file = def &= typFile &= help log_file_help, + log_level = def &= typ "LEVEL" &= help log_level_help, + output_directory = def &= typDir &= help output_directory_help, + password = def &= typ "PASSWORD" &= help password_help, + pidfile = def &= typFile &= help pidfile_help, + run_as_group = def &= typ "GROUP" &= help run_as_group_help, + run_as_user = def &= typ "USER" &= help run_as_user_help, + syslog = def &= typ "BOOL" &= help syslog_help, + username = def &= typ "USERNAME" &= help username_help } &= program program_name &= summary my_summary &= details [description]