From 792d0dca0527950bd501a7c60a95dbffe0bea142 Mon Sep 17 00:00:00 2001 From: Joshua Clayton Date: Thu, 2 Jun 2016 08:22:53 -0400 Subject: [PATCH] Minor reorganization within Main.hs --- app/Main.hs | 12 ++++-------- src/Unused/CLI/Views/SearchResult.hs | 3 ++- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index d3950dd..89b30b8 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -9,7 +9,7 @@ import Unused.TermSearch (SearchResults(..), fromResults) import Unused.ResultsClassifier import Unused.ResponseFilter (withOneOccurrence, withLikelihoods, ignoringPaths) import Unused.Grouping (CurrentGrouping(..), groupedResponses) -import Unused.CLI (SearchRunner(..), withoutCursor, renderHeader, executeSearch, resetScreen, withInterruptHandler) +import Unused.CLI (SearchRunner(..), withoutCursor, renderHeader, executeSearch, withInterruptHandler) import qualified Unused.CLI.Views as V import Unused.Cache import Unused.Aliases (termsAndAliases) @@ -27,7 +27,7 @@ data Options = Options } main :: IO () -main = withInterruptHandler $ +main = withInterruptHandler $ withoutCursor $ run =<< execParser (withInfo parseOptions pHeader pDescription pFooter) where @@ -38,7 +38,7 @@ main = withInterruptHandler $ pFooter = "CLI USAGE: $ unused" run :: Options -> IO () -run options = withoutCursor $ do +run options = do hSetBuffering stdout NoBuffering terms' <- calculateTagInput options @@ -53,11 +53,7 @@ run options = withoutCursor $ do renderHeader terms results <- withCache options $ executeSearch (oSearchRunner options) terms - let response = parseResults languageConfig results - - resetScreen - - printResults options response + printResults options $ parseResults languageConfig results return () diff --git a/src/Unused/CLI/Views/SearchResult.hs b/src/Unused/CLI/Views/SearchResult.hs index f85ac7d..601c12e 100644 --- a/src/Unused/CLI/Views/SearchResult.hs +++ b/src/Unused/CLI/Views/SearchResult.hs @@ -16,7 +16,8 @@ import qualified Unused.CLI.Views.NoResultsFound as V type ResultsPrinter = ReaderT ColumnFormat IO searchResults :: [GroupedTerms] -> IO () -searchResults terms = +searchResults terms = do + resetScreen runReaderT (printFormattedTerms terms) columnFormat where columnFormat = buildColumnFormatter $ termsToResults terms