Extract option filtering to separate function

This commit is contained in:
Joshua Clayton 2016-05-07 15:39:09 -04:00
parent 8fe09791c0
commit 9436f733b2

View File

@ -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