mirror of
https://github.com/joshuaclayton/unused.git
synced 2024-10-26 05:07:35 +03:00
Add switch to display all term results
This commit is contained in:
parent
4fc984ce75
commit
cb6eb12af4
12
app/Main.hs
12
app/Main.hs
@ -9,6 +9,7 @@ import Unused.CLI (SearchRunner(..), executeSearch, printParseError, printSearch
|
||||
|
||||
data Options = Options
|
||||
{ oSearchRunner :: SearchRunner
|
||||
, oAllOccurrencesAndFiles :: Bool
|
||||
}
|
||||
|
||||
main :: IO ()
|
||||
@ -34,17 +35,18 @@ withInfo :: Parser a -> String -> ParserInfo a
|
||||
withInfo opts desc = info (helper <*> opts) $ progDesc desc
|
||||
|
||||
optionFilters :: Options -> (ParseResponse -> ParseResponse)
|
||||
optionFilters _ =
|
||||
optionFilters o =
|
||||
foldl1 (.) filters
|
||||
where
|
||||
filters =
|
||||
[ withOneOccurrence . withOneFile
|
||||
[ if oAllOccurrencesAndFiles o then id else withOneOccurrence . withOneFile
|
||||
]
|
||||
|
||||
parseOptions :: Parser Options
|
||||
parseOptions =
|
||||
Options
|
||||
<$> parseSearchRunner
|
||||
<*> parseDisplayAllMatches
|
||||
|
||||
parseSearchRunner :: Parser SearchRunner
|
||||
parseSearchRunner =
|
||||
@ -52,3 +54,9 @@ parseSearchRunner =
|
||||
short 'P'
|
||||
<> long "no-progress"
|
||||
<> help "Don't display progress during analysis"
|
||||
|
||||
parseDisplayAllMatches :: Parser Bool
|
||||
parseDisplayAllMatches = switch $
|
||||
short 'a'
|
||||
<> long "all"
|
||||
<> help "Display all files and occurrences"
|
||||
|
Loading…
Reference in New Issue
Block a user