mirror of
https://github.com/joshuaclayton/unused.git
synced 2024-09-11 04:45:28 +03:00
Extract option filtering to separate function
This commit is contained in:
parent
8fe09791c0
commit
9436f733b2
11
app/Main.hs
11
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
|
||||
|
Loading…
Reference in New Issue
Block a user