1 -- | Parse the command-line options, and display help text if
9 import System.Console.CmdArgs (
20 import Paths_htsn_import ( version ) -- These let us get the
21 import Data.Version ( showVersion ) -- version from Cabal.
24 import OptionalConfiguration ( OptionalConfiguration(..) )
27 -- | The description of the program, displayed as part of the help.
29 description = "Import XML files from The Sports Network into an RDBMS."
32 -- | The name of this program.
33 program_name :: String
34 program_name = "htsn-import"
37 -- | A summary string output as part of the help.
39 my_summary = program_name ++ "-" ++ (showVersion version)
42 -- | A description of the "backend" option.
43 backend_help :: String
45 "Database choice, either \"Sqlite\" or \"Postgres\"."
48 -- | A description of the "connection_string" option.
49 connection_string_help :: String
50 connection_string_help =
51 "A database-specific connection string (depends on the backend)."
54 -- | A description of the "log_file" option.
55 log_file_help :: String
57 "Log to the given file."
60 -- | A description of the "log_level" option.
61 log_level_help :: String
63 "How verbose should the logs be? One of INFO, WARNING, ERROR."
66 -- | A description of the "remove" option.
69 "Remove files that have been successfully imported."
72 -- | A description of the "syslog" option.
75 "Enable logging to syslog."
78 -- | A data structure representing the possible command-line
79 -- options. The CmdArgs library is doing heavy magic beneath the
82 arg_spec :: OptionalConfiguration
84 OptionalConfiguration {
85 backend = def &= typ "BACKEND" &= help backend_help,
86 connection_string = def &= typ "STRING" &= help connection_string_help,
87 log_file = def &= typFile &= help log_file_help,
88 log_level = def &= typ "LEVEL" &= help log_level_help,
89 remove = def &= typ "BOOL" &= help remove_help,
90 syslog = def &= typ "BOOL" &= help syslog_help,
91 xml_files = def &= typ "XMLFILES" &= args }
92 &= program program_name
94 &= details [description]
97 -- | A convenience function; our only export. Meant to be used in
98 -- 'main' to retrieve the command-line arguments.
100 get_args :: IO OptionalConfiguration
101 get_args = cmdArgs arg_spec