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 ( OptionalConfiguration(..) )
23 description = "Count mailboxes in a SQL database."
25 program_name :: String
26 program_name = "mailbox-count"
29 my_summary = program_name ++ "-" ++ (showVersion version)
31 database_help :: String
33 "The name of the database (or file, if SQLite) to which we should connect"
37 "Produce a detailed report listing all mailboxes by domain"
39 detail_query_help :: String
41 "SQL query used to produce the detail report"
45 "Hostname where the database is located (postgres-only)"
47 password_help :: String
49 "Password used to connect to the database (postgres-only)"
53 "Port number used to connect to the database (postgres-only)"
55 summary_query_help :: String
57 "SQL query used to produce the summary report"
59 username_help :: String
61 "Username used to connect to the database (postgres-only)"
63 arg_spec :: OptionalConfiguration
65 OptionalConfiguration {
66 database = def &= help database_help,
67 detail = def &= help detail_help,
68 detail_query = def &= help detail_query_help,
69 host = def &= help host_help,
70 password = def &= help password_help,
71 port = def &= help port_help,
72 summary_query = def &= help summary_query_help,
73 username = def &= help username_help }
74 &= program program_name
76 &= details [description]
78 get_args :: IO OptionalConfiguration
79 get_args = cmdArgs arg_spec