1 module CommandLine ( get_args )
4 import System.Console.CmdArgs (
15 -- This let's us get the version from Cabal.
16 import Paths_harbl ( version )
17 import Data.Version ( showVersion )
21 import OptionalConfiguration ( OptionalConfiguration(..) )
23 -- | The description of the program, displayed as part of the help.
25 description = "Perform black- and white-list lookups on hosts."
28 -- | The name of this program.
29 program_name :: String
30 program_name = "harbl"
33 -- | A summary string output as part of the help.
35 my_summary = program_name ++ "-" ++ (showVersion version)
38 -- | A description of the \"lists\" option.
41 "A list of RBLs to check. See the manual for advanced syntax."
44 -- | A description of the \"threshold\" option.
45 threshold_help :: String
47 "The \"score\" a host must have to be considered blacklisted."
50 -- | A data structure representing the possible command-line
51 -- options. The CmdArgs library is doing heavy magic beneath the
54 arg_spec :: OptionalConfiguration
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
62 &= details [description]
65 -- | A convenience function; our only export. Meant to be used in
66 -- 'main' to retrieve the command-line arguments.
68 get_args :: IO OptionalConfiguration
69 get_args = cmdArgs arg_spec