]> gitweb.michael.orlitzky.com - list-remote-forwards.git/blob - src/CommandLine.hs
Initial commit of something working.
[list-remote-forwards.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_list_remote_forwards ( version )
17 import Data.Version ( showVersion )
18
19 import OptionalConfiguration ( OptionalConfiguration(..) )
20
21
22 description :: String
23 description =
24 "List all remote forwards for mail accounts stored in a SQL database."
25
26 program_name :: String
27 program_name = "list-remote-forwards"
28
29 my_summary :: String
30 my_summary = program_name ++ "-" ++ (showVersion version)
31
32 database_help :: String
33 database_help =
34 "The name of the database (or file, if SQLite) to which we should connect"
35
36 domain_query_help :: String
37 domain_query_help =
38 "SQL query used to produce the list of local domains"
39
40 exclude_mx_help :: String
41 exclude_mx_help =
42 "MX for whom we don't report remote forwards"
43
44 forward_query_help :: String
45 forward_query_help =
46 "SQL query used to produce the list of forwards, i.e. (to,from) pairs"
47
48 host_help :: String
49 host_help =
50 "Hostname where the database is located (postgres-only)"
51
52 password_help :: String
53 password_help =
54 "Password used to connect to the database (postgres-only)"
55
56 port_help :: String
57 port_help =
58 "Port number used to connect to the database (postgres-only)"
59
60 username_help :: String
61 username_help =
62 "Username used to connect to the database (postgres-only)"
63
64 arg_spec :: OptionalConfiguration
65 arg_spec =
66 OptionalConfiguration {
67 database = def &= help database_help,
68 domain_query = def &= help domain_query_help,
69 exclude_mx = def &= help exclude_mx_help,
70 forward_query = def &= help forward_query_help,
71 host = def &= help host_help,
72 password = def &= help password_help,
73 port = def &= help port_help,
74 username = def &= help username_help }
75 &= program program_name
76 &= summary my_summary
77 &= details [description]
78
79 get_args :: IO OptionalConfiguration
80 get_args = cmdArgs arg_spec