import CommandLine (help_set,
help_text,
input_function,
- parse_errors)
+ Mode(..),
+ parse_errors,
+ parse_mode)
-- Some exit codes, used in the ExitFailure constructor.
exit_invalid_cidr :: Int
-- The input function we receive here should know what to read.
inputfunc <- (CommandLine.input_function)
input <- inputfunc
+
let cidr_strings = lines input
mapM validate_or_die cidr_strings
let cidrs = map Cidr.from_string cidr_strings
- let regexes = map cidr_to_regex cidrs
- putStrLn $ alternate regexes
+
+ -- 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
+ putStr input