Add a "threshold" to the configuration.
[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 \"lists\" 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 description of the \"threshold\" option.
45 threshold_help :: String
46 threshold_help =
47 "The \"score\" a host must have to be considered blacklisted."
48
49
50 -- | A data structure representing the possible command-line
51 -- options. The CmdArgs library is doing heavy magic beneath the
52 -- hood here.
53 --
54 arg_spec :: OptionalConfiguration
55 arg_spec =
56 OptionalConfiguration {
57 hosts = def &= typ "HOSTS" &= args,
58 lists = def &= typ "RBLs" &= help lists_help,
59 threshold = def &= typ "INTEGER" &= help threshold_help }
60 &= program program_name
61 &= summary my_summary
62 &= details [description]
63
64
65 -- | A convenience function; our only export. Meant to be used in
66 -- 'main' to retrieve the command-line arguments.
67 --
68 get_args :: IO OptionalConfiguration
69 get_args = cmdArgs arg_spec