1 -- | Parse the command-line options, and display help text if
7 import System.Console.CmdArgs (
19 -- This let's us get the version from Cabal.
20 import Paths_htsn (version)
21 import Data.Version (showVersion)
23 import OptionalConfiguration (OptionalConfiguration(..))
26 -- | The description of the program, displayed as part of the help.
28 description = "Parse XML files from The Sports Network feed."
30 -- | The name of this program.
31 program_name :: String
34 -- | A summary string output as part of the help.
36 my_summary = program_name ++ "-" ++ (showVersion version)
39 -- | A description of the "log_file" option.
40 log_file_help :: String
42 "If syslog == False, log to the given file."
44 log_level_help :: String
46 "How verbose should the logs be? One of INFO, WARNING, ERROR."
48 -- | A description of the "password" option.
49 password_help :: String
51 "Password to use when connecting to the feed"
53 -- | A description of the "output_directory" option.
54 output_directory_help :: String
55 output_directory_help =
56 "Directory in which to output the XML files; must be writable"
58 -- | A description of the "syslog" option.
61 "Enable (default) or disable logging to syslog."
63 -- | A description of the "username" option.
64 username_help :: String
66 "Username to use when connecting to the feed"
68 -- | A data structure representing the possible command-line
69 -- options. The CmdArgs library is doing heavy magic beneath the
71 arg_spec :: OptionalConfiguration
73 OptionalConfiguration {
74 log_file = def &= typFile &= help log_file_help,
75 log_level = def &= typ "LEVEL" &= help log_level_help,
76 password = def &= typ "PASSWORD" &= help password_help,
77 output_directory = def &= typDir &= help output_directory_help,
78 syslog = def &= typ "BOOL" &= help syslog_help,
79 username = def &= typ "USERNAME" &= help username_help,
80 feed_hosts = def &= typ "HOSTNAMES" }
81 &= program program_name
83 &= details [description]
86 -- | A convenience function; our only export. Meant to be used in
87 -- 'main' to retrieve the command-line arguments.
88 get_args :: IO OptionalConfiguration
89 get_args = cmdArgs arg_spec