+ 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)
+ Diff -> do
+ _ <- mapM putStrLn deletions
+ _ <- mapM putStrLn additions
+ return ()
+ where
+ dupes = cidrs \\ (combine_all cidrs)
+ deletions = map (\s -> "-" ++ (show s)) dupes
+ newcidrs = (combine_all cidrs) \\ cidrs
+ additions = map (\s -> "+" ++ (show s)) newcidrs