]> gitweb.michael.orlitzky.com - mailbox-count.git/blob - src/CommandLine.hs
mailbox-count.cabal: bump to version 0.0.8
[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 (
20 OptionalConfiguration(
21 OptionalConfiguration,
22 database,
23 detail,
24 detail_query,
25 host,
26 password,
27 port,
28 summary_query,
29 username )
30 )
31
32
33 description :: String
34 description = "Count mailboxes in a SQL database."
35
36 program_name :: String
37 program_name = "mailbox-count"
38
39 my_summary :: String
40 my_summary = program_name ++ "-" ++ (showVersion version)
41
42 database_help :: String
43 database_help =
44 "The name of the database (or file, if SQLite) to which we should connect"
45
46 detail_help :: String
47 detail_help =
48 "Produce a detailed report listing all mailboxes by domain"
49
50 detail_query_help :: String
51 detail_query_help =
52 "SQL query used to produce the detail report"
53
54 host_help :: String
55 host_help =
56 "Hostname where the database is located (postgres-only)"
57
58 password_help :: String
59 password_help =
60 "Password used to connect to the database (postgres-only)"
61
62 port_help :: String
63 port_help =
64 "Port number used to connect to the database (postgres-only)"
65
66 summary_query_help :: String
67 summary_query_help =
68 "SQL query used to produce the summary report"
69
70 username_help :: String
71 username_help =
72 "Username used to connect to the database (postgres-only)"
73
74 arg_spec :: OptionalConfiguration
75 arg_spec =
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
86 &= summary my_summary
87 &= details [description]
88
89 get_args :: IO OptionalConfiguration
90 get_args = cmdArgs arg_spec