Add number of files and number of occurrences

This commit is contained in:
Joshua Clayton 2016-05-04 20:51:41 -04:00
parent 00c239fddb
commit 50399ec4b1

View File

@ -18,8 +18,13 @@ main = do
case withOneOccurrence $ withOneFile response of
Right termMatchSet -> do
clearScreen
let responses = responsesGroupedByPath termMatchSet
mapM_ printDirectorySection responses
mapM_ (printDirectorySection $ maxWidth) responses
where
responses = responsesGroupedByPath termMatchSet
allSets = listFromMatchSet =<< map snd responses
allResults = fmap snd allSets
termLength = return . length . tmTerm
maxWidth = maximum $ termLength =<< trMatches =<< allResults
Left e ->
printParseError e
@ -77,16 +82,11 @@ printAnalysisHeader terms = do
setSGR [Reset]
putStr " terms\n\n"
printDirectorySection :: (DirectoryPrefix, TermMatchSet) -> IO ()
printDirectorySection (dir, ss) = do
printDirectorySection :: Int -> (DirectoryPrefix, TermMatchSet) -> IO ()
printDirectorySection w (dir, ss) = do
printDirectory dir
mapM_ (printTermResults maxWidth) $ allSets
mapM_ (printTermResults w) $ listFromMatchSet ss
putStr "\n"
where
allSets = listFromMatchSet ss
allResults = fmap snd allSets
termLength = return . length . tmTerm
maxWidth = maximum $ termLength =<< trMatches =<< allResults
printDirectory :: DirectoryPrefix -> IO ()
printDirectory (DirectoryPrefix dir) = do
@ -111,6 +111,12 @@ printMatches w r ms =
setSGR [SetConsoleIntensity NormalIntensity]
putStr $ " " ++ (printf termFormat $ tmTerm m)
setSGR [Reset]
setSGR [SetColor Foreground Vivid Cyan]
setSGR [SetConsoleIntensity NormalIntensity]
putStr $ (printNumber $ trTotalFiles r) ++ "," ++ (printNumber $ trTotalOccurrences r) ++ " "
setSGR [Reset]
setSGR [SetColor Foreground Dull Cyan]
setSGR [SetConsoleIntensity FaintIntensity]
putStr $ " " ++ tmPath m
@ -118,6 +124,7 @@ printMatches w r ms =
putStr "\n"
where
termFormat = "%-" ++ (show w) ++ "s"
printNumber = printf "%2d"
printParseError :: ParseError -> IO ()
printParseError e = do