From cb6eb12af4c3ce5305779998f3f7b7262e610e93 Mon Sep 17 00:00:00 2001 From: Joshua Clayton Date: Sat, 7 May 2016 16:18:49 -0400 Subject: [PATCH] Add switch to display all term results --- app/Main.hs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index ebdd039..0dd4404 100644 --- a/app/Main.hs +++ b/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"