1 -- | Parse the command-line options, and display help text if
7 import System.Console.CmdArgs (
20 -- This let's us get the version from Cabal.
21 import Paths_htsn (version)
22 import Data.Version (showVersion)
24 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 "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 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 -- Use an empty list for feed_hosts since cmdargs will appends to
75 -- the default when the user supplies feed hosts. If he specifies
76 -- any, those are all we should use.
77 feed_hosts = def &= typ "HOSTNAMES" &= args,
78 log_file = def &= typFile &= help log_file_help,
79 log_level = def &= typ "LEVEL" &= help log_level_help,
80 password = def &= typ "PASSWORD" &= help password_help,
81 output_directory = def &= typDir &= help output_directory_help,
82 syslog = def &= typ "BOOL" &= help syslog_help,
83 username = def &= typ "USERNAME" &= help username_help }
84 &= program program_name
86 &= details [description]
89 -- | A convenience function; our only export. Meant to be used in
90 -- 'main' to retrieve the command-line arguments.
91 get_args :: IO OptionalConfiguration
92 get_args = cmdArgs arg_spec