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(..) )
25 import TSN.FeedHosts ( FeedHosts(..) )
27 -- | The description of the program, displayed as part of the help.
29 description = "Parse XML files from The Sports Network feed."
31 -- | The name of this program.
32 program_name :: String
35 -- | A summary string output as part of the help.
37 my_summary = program_name ++ "-" ++ (showVersion version)
40 -- | A description of the "log_file" option.
41 log_file_help :: String
43 "If syslog == False, log to the given file."
45 log_level_help :: String
47 "How verbose should the logs be? One of INFO, WARNING, ERROR."
49 -- | A description of the "password" option.
50 password_help :: String
52 "Password to use when connecting to the feed"
54 -- | A description of the "output_directory" option.
55 output_directory_help :: String
56 output_directory_help =
57 "Directory in which to output the XML files; must be writable"
59 -- | A description of the "syslog" option.
62 "Enable (default) or disable logging to syslog."
64 -- | A description of the "username" option.
65 username_help :: String
67 "Username to use when connecting to the feed"
69 -- | A data structure representing the possible command-line
70 -- options. The CmdArgs library is doing heavy magic beneath the
72 arg_spec :: OptionalConfiguration
74 OptionalConfiguration {
75 -- Use an empty list for feed_hosts since cmdargs will appends to
76 -- the default when the user supplies feed hosts. If he specifies
77 -- any, those are all we should use.
78 feed_hosts = FeedHosts [] &= typ "HOSTNAMES" &= args,
79 log_file = def &= typFile &= help log_file_help,
80 log_level = def &= typ "LEVEL" &= help log_level_help,
81 password = def &= typ "PASSWORD" &= help password_help,
82 output_directory = def &= typDir &= help output_directory_help,
83 syslog = def &= typ "BOOL" &= help syslog_help,
84 username = def &= typ "USERNAME" &= help username_help }
85 &= program program_name
87 &= details [description]
90 -- | A convenience function; our only export. Meant to be used in
91 -- 'main' to retrieve the command-line arguments.
92 get_args :: IO OptionalConfiguration
93 get_args = cmdArgs arg_spec