From 9436f733b2098c956e90a24643e355142a9df08e Mon Sep 17 00:00:00 2001 From: Joshua Clayton Date: Sat, 7 May 2016 15:39:09 -0400 Subject: [PATCH] Extract option filtering to separate function --- app/Main.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Main.hs b/app/Main.hs index d51185d..a00ab2b 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -3,6 +3,7 @@ module Main where import Options.Applicative import System.IO (hSetBuffering, BufferMode(NoBuffering), stdout) import Unused.Parser (parseLines) +import Unused.Types (ParseResponse) import Unused.ResponseFilter (withOneOccurrence, withOneFile) import Unused.CLI (SearchRunner(..), executeSearch, printParseError, printSearchResults, resetScreen) @@ -25,13 +26,21 @@ run options = do resetScreen either printParseError printSearchResults $ - withOneOccurrence $ withOneFile response + optionFilters options response return () withInfo :: Parser a -> String -> ParserInfo a withInfo opts desc = info (helper <*> opts) $ progDesc desc +optionFilters :: Options -> (ParseResponse -> ParseResponse) +optionFilters _ = + foldl1 (.) filters + where + filters = + [ withOneOccurrence . withOneFile + ] + parseOptions :: Parser Options parseOptions = Options