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_import (version)
21 import Data.Version (showVersion)
23 import OptionalConfiguration ( OptionalConfiguration(..) )
25 -- | The description of the program, displayed as part of the help.
27 description = "Import XML files from The Sports Network into an RDBMS."
29 -- | The name of this program.
30 program_name :: String
31 program_name = "htsn-import"
33 -- | A summary string output as part of the help.
35 my_summary = program_name ++ "-" ++ (showVersion version)
37 -- | A description of the "backend" option.
38 backend_help :: String
40 "Database choice, either \"Sqlite\" or \"Postgres\"."
42 -- | A description of the "connection_string" option.
43 connection_string_help :: String
44 connection_string_help =
45 "A database-specific connection string (depends on the backend)."
47 -- | A description of the "log_file" option.
48 log_file_help :: String
50 "Log to the given file."
52 -- | A description of the "log_level" option.
53 log_level_help :: String
55 "How verbose should the logs be? One of INFO, WARNING, ERROR."
57 -- | A description of the "syslog" option.
60 "Enable logging to syslog."
63 -- | A data structure representing the possible command-line
64 -- options. The CmdArgs library is doing heavy magic beneath the
66 arg_spec :: OptionalConfiguration
68 OptionalConfiguration {
69 backend = def &= typ "BACKEND" &= help backend_help,
70 connection_string = def &= typ "STRING" &= help connection_string_help,
71 log_file = def &= typFile &= help log_file_help,
72 log_level = def &= typ "LEVEL" &= help log_level_help,
73 syslog = def &= typ "BOOL" &= help syslog_help,
74 xml_files = def &= typ "XMLFILES" &= args }
75 &= program program_name
77 &= details [description]
80 -- | A convenience function; our only export. Meant to be used in
81 -- 'main' to retrieve the command-line arguments.
82 get_args :: IO OptionalConfiguration
83 get_args = cmdArgs arg_spec