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