]> gitweb.michael.orlitzky.com - mailbox-count.git/blob - src/CommandLine.hs
Add SQLite support (default if a filename is given as the database).
[mailbox-count.git] / src / CommandLine.hs
1 module CommandLine (
2 get_args )
3 where
4
5 import System.Console.CmdArgs (
6 (&=),
7 cmdArgs,
8 def,
9 details,
10 help,
11 program,
12 summary )
13
14
15 -- Get the version from Cabal.
16 import Paths_mailbox_count ( version )
17 import Data.Version ( showVersion )
18
19 import OptionalConfiguration ( OptionalConfiguration(..) )
20
21
22 description :: String
23 description = "Count mailboxes in a SQL database."
24
25 program_name :: String
26 program_name = "mailbox-count"
27
28 my_summary :: String
29 my_summary = program_name ++ "-" ++ (showVersion version)
30
31 database_help :: String
32 database_help =
33 "The name of the database (or file, if SQLite) to which we should connect"
34
35 detail_help :: String
36 detail_help =
37 "Produce a detailed report listing all mailboxes by domain"
38
39 detail_query_help :: String
40 detail_query_help =
41 "SQL query used to produce the detail report"
42
43 host_help :: String
44 host_help =
45 "Hostname where the database is located (postgres-only)"
46
47 password_help :: String
48 password_help =
49 "Password used to connect to the database (postgres-only)"
50
51 port_help :: String
52 port_help =
53 "Port number used to connect to the database (postgres-only)"
54
55 summary_query_help :: String
56 summary_query_help =
57 "SQL query used to produce the summary report"
58
59 username_help :: String
60 username_help =
61 "Username used to connect to the database (postgres-only)"
62
63 arg_spec :: OptionalConfiguration
64 arg_spec =
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
75 &= summary my_summary
76 &= details [description]
77
78 get_args :: IO OptionalConfiguration
79 get_args = cmdArgs arg_spec