import Cidr (Cidr(..),
cidr_from_string,
- is_valid_cidr)
+ combine_all)
import CommandLine (help_set,
help_text,
upper = maximum [x,y]
--- Take a CIDR String, and exit with a failure if it's invalid.
-validate_or_die :: String -> IO ()
-validate_or_die cidr = do
- if (Cidr.is_valid_cidr cidr)
- then do
- return ()
- else do
- putStrLn "Error: not valid CIDR notation."
- exitWith (ExitFailure exit_invalid_cidr)
-
-
-
main :: IO ()
main = do
-- First, check for any errors that occurred while parsing
input <- inputfunc
let cidr_strings = lines input
- mapM validate_or_die cidr_strings
let cidrs = map Cidr.cidr_from_string cidr_strings
+ if (any (== Cidr.None) cidrs)
+ then do
+ putStrLn "Error: not valid CIDR notation."
+ exitWith (ExitFailure exit_invalid_cidr)
+ else do -- Nothing
+
-- Get the mode of operation.
mode <- CommandLine.parse_mode
let regexes = map cidr_to_regex cidrs
putStrLn $ alternate regexes
Reduce -> do
- putStr input
+ mapM (putStrLn . show) (combine_all cidrs)
+ return ()