X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FCommandLine.hs;h=9d409ac89c6fb07852d06a8e002a80796458ce4f;hb=e42a9a84c3866b7293abb98735c3e76bd12c4dda;hp=d0cf6f4f76bd7cdf038afa0be41f6510615674eb;hpb=006f90418a578308104b75362f0b595466900eed;p=hath.git diff --git a/src/CommandLine.hs b/src/CommandLine.hs index d0cf6f4..9d409ac 100644 --- a/src/CommandLine.hs +++ b/src/CommandLine.hs @@ -16,7 +16,6 @@ import System.Console.CmdArgs ( Ann, Annotate( (:=) ), Data, - Typeable, (+=), auto, cmdArgs_, @@ -50,22 +49,27 @@ barriers_help = "(regexed mode) place barriers in front/back of the regex " ++ "to prevent e.g. '127.0.0.1' from matching '127.0.0.100'" +normalize_help :: String +normalize_help = + "(reduced mode) normalize the output CIDRS, replacing any " ++ + "masked bits by zeros; e.g. '127.0.0.1/8' -> '127.0.0.0/8'" + -- | The Args type represents the possible command-line options. The -- duplication here seems necessary; CmdArgs' magic requires us to -- define some things explicitly. -- --- The application currently has six modes (if this number is wrong, +-- The application currently has five modes (if this number is wrong, -- it means I forgot to update the comment!), all of which take the -- same options and arguments. -- data Args = - Regexed { barriers :: Bool } | - Reduced { barriers :: Bool } | - Duped { barriers :: Bool } | - Diffed { barriers :: Bool } | - Listed { barriers :: Bool } - deriving (Data, Show, Typeable) + Regexed { barriers :: Bool, normalize :: Bool } | + Reduced { barriers :: Bool, normalize :: Bool } | + Duped { barriers :: Bool, normalize :: Bool } | + Diffed { barriers :: Bool, normalize :: Bool } | + Listed { barriers :: Bool, normalize :: Bool } + deriving (Data, Show) -- | Description of the 'Regexed' mode. regexed_description :: String @@ -109,12 +113,16 @@ arg_spec = name "v", groupname "Common flags"] where - make_mode :: (Bool -> Args) -> String -> (Annotate Ann) + make_mode :: (Bool -> Bool -> Args) -> String -> (Annotate Ann) make_mode ctor desc = - record (ctor def) [ barriers := def - += groupname "Common flags" - += help barriers_help ] - += details [" " ++ desc] + record (ctor def def) + [ barriers := def + += groupname "Common flags" + += help barriers_help, + normalize := def + += groupname "Common flags" + += help normalize_help ] + += details [" " ++ desc] regexed = make_mode Regexed regexed_description reduced = make_mode Reduced reduced_description