- mapM validate_or_die cidr_strings
- let cidrs = map Cidr.from_string cidr_strings
- let regexes = map cidr_to_regex cidrs
- putStrLn $ alternate regexes
+ 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
+
+ case mode of
+ Regex -> do
+ let regexes = map cidr_to_regex cidrs
+ putStrLn $ alternate regexes
+ Reduce -> do
+ mapM (putStrLn . show) (combine_all cidrs)
+ return ()
+ Dupe -> do
+ mapM (putStrLn . show) dupes
+ return ()
+ where
+ dupes = cidrs \\ (combine_all cidrs)