1 -- | Parse the command-line options, and display help text if
7 import System.Console.CmdArgs (
18 -- This let's us get the version from Cabal.
19 import Paths_htsn (version)
20 import Data.Version (showVersion)
22 import OptionalConfiguration (OptionalConfiguration(..))
25 -- | The description of the program, displayed as part of the help.
27 description = "Parse XML files from The Sports Network feed."
29 -- | The name of this program.
30 program_name :: String
33 -- | A summary string output as part of the help.
35 my_summary = program_name ++ "-" ++ (showVersion version)
38 -- | A description of the "password" option.
39 password_help :: String
41 "Password to use when connecting to the feed"
43 -- | A description of the "output_directory" option.
44 output_directory_help :: String
45 output_directory_help =
46 "Directory in which to output the XML files; must be writable"
48 -- | A description of the "username" option.
49 username_help :: String
51 "Username to use when connecting to the feed"
53 -- | A data structure representing the possible command-line
54 -- options. The CmdArgs library is doing heavy magic beneath the
56 arg_spec :: OptionalConfiguration
58 OptionalConfiguration {
59 password = def &= typ "PASSWORD" &= help password_help,
60 output_directory = def &= typDir &= help output_directory_help,
61 username = def &= typ "USERNAME" &= help username_help,
62 feed_hosts = def &= typ "HOSTNAMES" }
63 &= program program_name
65 &= details [description]
68 -- | A convenience function; our only export. Meant to be used in
69 -- 'main' to retrieve the command-line arguments.
70 get_args :: IO OptionalConfiguration
71 get_args = cmdArgs arg_spec