]> gitweb.michael.orlitzky.com - mailbox-count.git/blob - src/CommandLine.hs
Begin throwing real code together.
[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 both_help :: String
34 both_help =
35 "Produce both summary and detailed reports"
36
37 database_help :: String
38 database_help =
39 "The name of the database to which we should connect"
40
41 detail_help :: String
42 detail_help =
43 "Produce a detailed report listing all mailboxes by domain"
44
45 host_help :: String
46 host_help =
47 "Hostname where the database is located"
48
49 password_help :: String
50 password_help =
51 "Password used to connect to the database"
52
53 port_help :: String
54 port_help =
55 "Port number used to connect to the database"
56
57 username_help :: String
58 username_help =
59 "Username used to connect to the database"
60
61 arg_spec :: OptionalConfiguration
62 arg_spec = OptionalConfiguration
63 { both = def &= help both_help,
64 database = def &= help database_help,
65 detail = def &= help detail_help,
66 host = def &= help host_help,
67 password = def &= help password_help,
68 port = def &= help port_help,
69 username = def &= help username_help }
70 &= program program_name
71 &= summary my_summary
72 &= details [description]
73
74 get_args :: IO OptionalConfiguration
75 get_args = cmdArgs arg_spec