]> gitweb.michael.orlitzky.com - mailbox-count.git/blob - src/CommandLine.hs
Align the mailbox counts in the summary report to the same column.
[mailbox-count.git] / src / CommandLine.hs
1 {-# LANGUAGE DeriveDataTypeable #-}
2
3 module CommandLine (
4 get_args )
5 where
6
7 import System.Console.CmdArgs (
8 (&=),
9 cmdArgs,
10 def,
11 details,
12 help,
13 program,
14 summary )
15
16
17 -- Get the version from Cabal.
18 import Paths_mailbox_count ( version )
19 import Data.Version ( showVersion )
20
21 import OptionalConfiguration ( OptionalConfiguration(..) )
22
23
24 description :: String
25 description = "Count mailboxes in a SQL database."
26
27 program_name :: String
28 program_name = "mailbox-count"
29
30 my_summary :: String
31 my_summary = program_name ++ "-" ++ (showVersion version)
32
33 database_help :: String
34 database_help =
35 "The name of the database to which we should connect"
36
37 detail_help :: String
38 detail_help =
39 "Produce a detailed report listing all mailboxes by domain"
40
41 host_help :: String
42 host_help =
43 "Hostname where the database is located"
44
45 password_help :: String
46 password_help =
47 "Password used to connect to the database"
48
49 port_help :: String
50 port_help =
51 "Port number used to connect to the database"
52
53 username_help :: String
54 username_help =
55 "Username used to connect to the database"
56
57 arg_spec :: OptionalConfiguration
58 arg_spec = OptionalConfiguration
59 { database = def &= help database_help,
60 detail = def &= help detail_help,
61 host = def &= help host_help,
62 password = def &= help password_help,
63 port = def &= help port_help,
64 username = def &= help username_help }
65 &= program program_name
66 &= summary my_summary
67 &= details [description]
68
69 get_args :: IO OptionalConfiguration
70 get_args = cmdArgs arg_spec