]> gitweb.michael.orlitzky.com - dead/harbl.git/blob - harbl-cli/src/CommandLine.hs
Replace 'UserDomain' with 'Host' in the library.
[dead/harbl.git] / harbl-cli / src / CommandLine.hs
1 module CommandLine ( get_args )
2 where
3
4 import System.Console.CmdArgs (
5 (&=),
6 args,
7 cmdArgs,
8 def,
9 details,
10 help,
11 program,
12 summary,
13 typ )
14
15 -- This let's us get the version from Cabal.
16 import Paths_harbl ( version )
17 import Data.Version ( showVersion )
18
19 import Hosts ()
20 import Lists ()
21 import OptionalConfiguration ( OptionalConfiguration(..) )
22
23 -- | The description of the program, displayed as part of the help.
24 description :: String
25 description = "Perform black- and white-list lookups on hosts."
26
27
28 -- | The name of this program.
29 program_name :: String
30 program_name = "harbl"
31
32
33 -- | A summary string output as part of the help.
34 my_summary :: String
35 my_summary = program_name ++ "-" ++ (showVersion version)
36
37
38 -- | A description of the "daemonize" option.
39 lists_help :: String
40 lists_help =
41 "A list of RBLs to check. See the manual for advanced syntax."
42
43
44 -- | A data structure representing the possible command-line
45 -- options. The CmdArgs library is doing heavy magic beneath the
46 -- hood here.
47 --
48 arg_spec :: OptionalConfiguration
49 arg_spec =
50 OptionalConfiguration {
51 hosts = def &= typ "HOSTS" &= args,
52 lists = def &= typ "RBLs" &= help lists_help }
53 &= program program_name
54 &= summary my_summary
55 &= details [description]
56
57
58 -- | A convenience function; our only export. Meant to be used in
59 -- 'main' to retrieve the command-line arguments.
60 --
61 get_args :: IO OptionalConfiguration
62 get_args = cmdArgs arg_spec