X-Git-Url: http://gitweb.michael.orlitzky.com/?p=hath.git;a=blobdiff_plain;f=src%2FCommandLine.hs;h=8ed8597fe25d62e7390882a460f0787a6c90e10a;hp=181eb6f01be210605058a1d51e6e246af210c063;hb=942b8ef3bc5830ca0defa62342d55550aea59934;hpb=81f6f0ca67347de6b3e3f57b5b50bb543cc7c146
diff --git a/src/CommandLine.hs b/src/CommandLine.hs
index 181eb6f..8ed8597 100644
--- a/src/CommandLine.hs
+++ b/src/CommandLine.hs
@@ -21,13 +21,25 @@ lowercase :: String -> String
lowercase = map toLower
--- | The application currently has four modes. The default, Regex,
+-- | The application currently has six modes. The default, Regex,
-- will compute a regular expression matching the input
--- CIDRs. Reduce, on the other hand, will combine any
--- redundant/adjacent CIDR blocks into one. Dupe will show you what
--- would be removed by Reduce, and Diff will show both additions and
--- deletions in a diff-like format.
-data Mode = Regex | Reduce | Dupe | Diff
+-- CIDRs.
+--
+-- Reduce, on the other hand, will combine any redundant/adjacent
+-- CIDR blocks into one.
+--
+-- Dupe will show you what would be removed by Reduce.
+--
+-- Diff will show both additions and deletions in a diff-like
+-- format.
+--
+-- List will enumerate the IP addresses contained within the input
+-- CIDRs.
+--
+-- Reverse will perform a reverse DNS (PTR) lookup on each IP
+-- address contained within the input CIDRs.
+--
+data Mode = Regex | Reduce | Dupe | Diff | List | Reverse
-- | A record containing values for all available options.
@@ -58,7 +70,7 @@ options =
-- | Takes an Options as an argument, and sets its opt_help member to
-- True.
set_help :: Options -> IO Options
-set_help opts =
+set_help opts =
return opts { opt_help = True }
@@ -73,7 +85,12 @@ set_input arg opts =
-- | The usage header.
usage :: String
-usage = "Usage: hath [regexed|reduced|duped|diffed] [-h] [-i FILE] "
+usage =
+ "Usage: hath " ++
+ "[regexed|reduced|duped|diffed|listed|reversed] " ++
+ "[-h] " ++
+ "[-i FILE] " ++
+ ""
-- | The usage header, and all available flags (as generated by GetOpt).
@@ -100,21 +117,25 @@ parse_mode :: IO Mode
parse_mode = do
argv <- getArgs
let (_, non_options, _) = getOpt Permute options argv
- case non_options of
+ return $ case non_options of
-- Default
- [] -> return Regex
- -- Some non-option was given, but were any of them modes?
+ [] -> Regex
+ -- Some non-option was given, but were any of them modes?
(x:_) ->
case (lowercase x) of
- "regex" -> return Regex
- "regexed" -> return Regex
- "reduce" -> return Reduce
- "reduced" -> return Reduce
- "dupe" -> return Dupe
- "duped" -> return Dupe
- "diff" -> return Diff
- "diffed" -> return Diff
- _ -> return Regex
+ "regex" -> Regex
+ "regexed" -> Regex
+ "reduce" -> Reduce
+ "reduced" -> Reduce
+ "dupe" -> Dupe
+ "duped" -> Dupe
+ "diff" -> Diff
+ "diffed" -> Diff
+ "list" -> List
+ "listed" -> List
+ "reverse" -> Reverse
+ "reversed" -> Reverse
+ _ -> Regex