mirror of
https://github.com/joshuaclayton/unused.git
synced 2024-09-11 04:45:28 +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
|
data Options = Options
|
||||||
{ oSearchRunner :: SearchRunner
|
{ oSearchRunner :: SearchRunner
|
||||||
|
, oAllOccurrencesAndFiles :: Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
@ -34,17 +35,18 @@ withInfo :: Parser a -> String -> ParserInfo a
|
|||||||
withInfo opts desc = info (helper <*> opts) $ progDesc desc
|
withInfo opts desc = info (helper <*> opts) $ progDesc desc
|
||||||
|
|
||||||
optionFilters :: Options -> (ParseResponse -> ParseResponse)
|
optionFilters :: Options -> (ParseResponse -> ParseResponse)
|
||||||
optionFilters _ =
|
optionFilters o =
|
||||||
foldl1 (.) filters
|
foldl1 (.) filters
|
||||||
where
|
where
|
||||||
filters =
|
filters =
|
||||||
[ withOneOccurrence . withOneFile
|
[ if oAllOccurrencesAndFiles o then id else withOneOccurrence . withOneFile
|
||||||
]
|
]
|
||||||
|
|
||||||
parseOptions :: Parser Options
|
parseOptions :: Parser Options
|
||||||
parseOptions =
|
parseOptions =
|
||||||
Options
|
Options
|
||||||
<$> parseSearchRunner
|
<$> parseSearchRunner
|
||||||
|
<*> parseDisplayAllMatches
|
||||||
|
|
||||||
parseSearchRunner :: Parser SearchRunner
|
parseSearchRunner :: Parser SearchRunner
|
||||||
parseSearchRunner =
|
parseSearchRunner =
|
||||||
@ -52,3 +54,9 @@ parseSearchRunner =
|
|||||||
short 'P'
|
short 'P'
|
||||||
<> long "no-progress"
|
<> long "no-progress"
|
||||||
<> help "Don't display progress during analysis"
|
<> 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