From: Michael Orlitzky Date: Mon, 13 Jul 2015 22:54:30 +0000 (-0400) Subject: Add a "new" exit code (shift them all, really) for a host being blacklisted. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=d124148390284252851e2973e60d1fe85380330d;p=dead%2Fharbl.git Add a "new" exit code (shift them all, really) for a host being blacklisted. --- diff --git a/harbl-cli/src/ExitCodes.hs b/harbl-cli/src/ExitCodes.hs index 472ea15..8459df7 100644 --- a/harbl-cli/src/ExitCodes.hs +++ b/harbl-cli/src/ExitCodes.hs @@ -2,31 +2,38 @@ -- ExitSuccess). -- module ExitCodes ( + exit_host_blacklisted, exit_no_hosts, exit_no_lists, exit_unparseable_host, exit_unparseable_list ) where +-- | The most common error: some host exceeded the blacklist +-- threshold. +exit_host_blacklisted :: Int +exit_host_blacklisted = 1 + + -- | No hosts were given on the command-line or in a config file. -- exit_no_hosts :: Int -exit_no_hosts = 1 +exit_no_hosts = 2 -- | No lists were given on the command-line or in a config file. -- exit_no_lists :: Int -exit_no_lists = 2 +exit_no_lists = 3 -- | The user gave us an RBL we couldn't parse. -- exit_unparseable_list :: Int -exit_unparseable_list = 3 +exit_unparseable_list = 4 -- | The user gave us a host we couldn't parse. -- exit_unparseable_host :: Int -exit_unparseable_host = 4 +exit_unparseable_host = 5 diff --git a/harbl-cli/src/Main.hs b/harbl-cli/src/Main.hs index d2ac8d2..7b28af5 100644 --- a/harbl-cli/src/Main.hs +++ b/harbl-cli/src/Main.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE DoAndIfThenElse #-} + module Main ( main ) where @@ -5,12 +7,13 @@ import Control.Monad ( liftM, when ) import Data.Monoid ( (<>) ) import Text.Parsec ( ParseError, parse ) import System.Console.CmdArgs ( def ) -import System.Exit ( exitWith, ExitCode (ExitFailure) ) +import System.Exit ( exitSuccess, exitWith, ExitCode (ExitFailure) ) import System.IO ( hPutStrLn, stderr ) import CommandLine ( get_args ) import Configuration ( Configuration(..), merge_optional ) import ExitCodes ( + exit_host_blacklisted, exit_no_hosts, exit_no_lists, exit_unparseable_host, @@ -80,3 +83,6 @@ main = do Right hs -> do listings <- concatMapM (lookup_rbl ls) hs mapM_ (putStrLn . listing_message) listings + if null listings + then exitSuccess + else exitWith (ExitFailure exit_host_blacklisted)