]> gitweb.michael.orlitzky.com - hath.git/blobdiff - src/CommandLine.hs
Bump the version number to 0.0.4 in hath.cabal.
[hath.git] / src / CommandLine.hs
index 181eb6f01be210605058a1d51e6e246af210c063..8ed8597fe25d62e7390882a460f0787a6c90e10a 100644 (file)
@@ -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] <input>"
+usage =
+  "Usage: hath " ++
+  "[regexed|reduced|duped|diffed|listed|reversed] " ++
+  "[-h] " ++
+  "[-i FILE] " ++
+  "<input>"
 
 
 -- | 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