mirror of
https://github.com/joshuaclayton/unused.git
synced 2024-09-11 04:45:28 +03:00
Add number of files and number of occurrences
This commit is contained in:
parent
00c239fddb
commit
50399ec4b1
27
app/Main.hs
27
app/Main.hs
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user