5 import System.Console.CmdArgs (
15 -- Get the version from Cabal.
16 import Paths_mailbox_count ( version )
17 import Data.Version ( showVersion )
19 import OptionalConfiguration (
20 OptionalConfiguration(
21 OptionalConfiguration,
34 description = "Count mailboxes in a SQL database."
36 program_name :: String
37 program_name = "mailbox-count"
40 my_summary = program_name ++ "-" ++ (showVersion version)
42 database_help :: String
44 "The name of the database (or file, if SQLite) to which we should connect"
48 "Produce a detailed report listing all mailboxes by domain"
50 detail_query_help :: String
52 "SQL query used to produce the detail report"
56 "Hostname where the database is located (postgres-only)"
58 password_help :: String
60 "Password used to connect to the database (postgres-only)"
64 "Port number used to connect to the database (postgres-only)"
66 summary_query_help :: String
68 "SQL query used to produce the summary report"
70 username_help :: String
72 "Username used to connect to the database (postgres-only)"
74 arg_spec :: OptionalConfiguration
76 OptionalConfiguration {
77 database = def &= help database_help,
78 detail = def &= help detail_help,
79 detail_query = def &= help detail_query_help,
80 host = def &= help host_help,
81 password = def &= help password_help,
82 port = def &= help port_help,
83 summary_query = def &= help summary_query_help,
84 username = def &= help username_help }
85 &= program program_name
87 &= details [description]
89 get_args :: IO OptionalConfiguration
90 get_args = cmdArgs arg_spec