]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blob - src/CommandLine.hs
Don't remove imported files by default.
[dead/htsn-import.git] / src / CommandLine.hs
1 -- | Parse the command-line options, and display help text if
2 -- necessary.
3 module CommandLine (
4 get_args )
5 where
6
7 import System.Console.CmdArgs (
8 (&=),
9 args,
10 cmdArgs,
11 def,
12 details,
13 help,
14 program,
15 summary,
16 typ,
17 typFile )
18
19 -- This let's us get the version from Cabal.
20 import Paths_htsn_import (version)
21 import Data.Version (showVersion)
22
23 import OptionalConfiguration ( OptionalConfiguration(..) )
24
25 -- | The description of the program, displayed as part of the help.
26 description :: String
27 description = "Import XML files from The Sports Network into an RDBMS."
28
29 -- | The name of this program.
30 program_name :: String
31 program_name = "htsn-import"
32
33 -- | A summary string output as part of the help.
34 my_summary :: String
35 my_summary = program_name ++ "-" ++ (showVersion version)
36
37 -- | A description of the "backend" option.
38 backend_help :: String
39 backend_help =
40 "Database choice, either \"Sqlite\" or \"Postgres\"."
41
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)."
46
47 -- | A description of the "log_file" option.
48 log_file_help :: String
49 log_file_help =
50 "Log to the given file."
51
52 -- | A description of the "log_level" option.
53 log_level_help :: String
54 log_level_help =
55 "How verbose should the logs be? One of INFO, WARNING, ERROR."
56
57 -- | A description of the "remove" option.
58 remove_help :: String
59 remove_help =
60 "Remove files that have been successfully imported."
61
62 -- | A description of the "syslog" option.
63 syslog_help :: String
64 syslog_help =
65 "Enable logging to syslog."
66
67
68 -- | A data structure representing the possible command-line
69 -- options. The CmdArgs library is doing heavy magic beneath the
70 -- hood here.
71 arg_spec :: OptionalConfiguration
72 arg_spec =
73 OptionalConfiguration {
74 backend = def &= typ "BACKEND" &= help backend_help,
75 connection_string = def &= typ "STRING" &= help connection_string_help,
76 log_file = def &= typFile &= help log_file_help,
77 log_level = def &= typ "LEVEL" &= help log_level_help,
78 remove = def &= typ "BOOL" &= help remove_help,
79 syslog = def &= typ "BOOL" &= help syslog_help,
80 xml_files = def &= typ "XMLFILES" &= args }
81 &= program program_name
82 &= summary my_summary
83 &= details [description]
84
85
86 -- | A convenience function; our only export. Meant to be used in
87 -- 'main' to retrieve the command-line arguments.
88 get_args :: IO OptionalConfiguration
89 get_args = cmdArgs arg_spec