X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=harbl-cli%2Fsrc%2FCommandLine.hs;fp=harbl-cli%2Fsrc%2FCommandLine.hs;h=a3481fef70c64a320a97163451cc5aaf8f41c1cb;hb=b55e5db2a68be5d69b970bbe4b5ad447881abd3d;hp=0000000000000000000000000000000000000000;hpb=c4d41b93ec02ff4dc762163441ebefb0324e6f07;p=dead%2Fharbl.git diff --git a/harbl-cli/src/CommandLine.hs b/harbl-cli/src/CommandLine.hs new file mode 100644 index 0000000..a3481fe --- /dev/null +++ b/harbl-cli/src/CommandLine.hs @@ -0,0 +1,62 @@ +module CommandLine ( get_args ) +where + +import System.Console.CmdArgs ( + (&=), + args, + cmdArgs, + def, + details, + help, + program, + summary, + typ ) + +-- This let's us get the version from Cabal. +import Paths_harbl ( version ) +import Data.Version ( showVersion ) + +import Hosts () +import Lists () +import OptionalConfiguration ( OptionalConfiguration(..) ) + +-- | The description of the program, displayed as part of the help. +description :: String +description = "Perform black- and white-list lookups on hosts." + + +-- | The name of this program. +program_name :: String +program_name = "harbl" + + +-- | A summary string output as part of the help. +my_summary :: String +my_summary = program_name ++ "-" ++ (showVersion version) + + +-- | A description of the "daemonize" option. +lists_help :: String +lists_help = + "A list of RBLs to check. See the manual for advanced syntax." + + +-- | A data structure representing the possible command-line +-- options. The CmdArgs library is doing heavy magic beneath the +-- hood here. +-- +arg_spec :: OptionalConfiguration +arg_spec = + OptionalConfiguration { + hosts = def &= typ "HOSTS" &= args, + lists = def &= typ "RBLs" &= help lists_help } + &= program program_name + &= summary my_summary + &= details [description] + + +-- | A convenience function; our only export. Meant to be used in +-- 'main' to retrieve the command-line arguments. +-- +get_args :: IO OptionalConfiguration +get_args = cmdArgs arg_spec