mirror of
https://github.com/joshuaclayton/unused.git
synced 2024-10-26 05:07:35 +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
|
case withOneOccurrence $ withOneFile response of
|
||||||
Right termMatchSet -> do
|
Right termMatchSet -> do
|
||||||
clearScreen
|
clearScreen
|
||||||
let responses = responsesGroupedByPath termMatchSet
|
mapM_ (printDirectorySection $ maxWidth) responses
|
||||||
mapM_ printDirectorySection 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 ->
|
Left e ->
|
||||||
printParseError e
|
printParseError e
|
||||||
|
|
||||||
@ -77,16 +82,11 @@ printAnalysisHeader terms = do
|
|||||||
setSGR [Reset]
|
setSGR [Reset]
|
||||||
putStr " terms\n\n"
|
putStr " terms\n\n"
|
||||||
|
|
||||||
printDirectorySection :: (DirectoryPrefix, TermMatchSet) -> IO ()
|
printDirectorySection :: Int -> (DirectoryPrefix, TermMatchSet) -> IO ()
|
||||||
printDirectorySection (dir, ss) = do
|
printDirectorySection w (dir, ss) = do
|
||||||
printDirectory dir
|
printDirectory dir
|
||||||
mapM_ (printTermResults maxWidth) $ allSets
|
mapM_ (printTermResults w) $ listFromMatchSet ss
|
||||||
putStr "\n"
|
putStr "\n"
|
||||||
where
|
|
||||||
allSets = listFromMatchSet ss
|
|
||||||
allResults = fmap snd allSets
|
|
||||||
termLength = return . length . tmTerm
|
|
||||||
maxWidth = maximum $ termLength =<< trMatches =<< allResults
|
|
||||||
|
|
||||||
printDirectory :: DirectoryPrefix -> IO ()
|
printDirectory :: DirectoryPrefix -> IO ()
|
||||||
printDirectory (DirectoryPrefix dir) = do
|
printDirectory (DirectoryPrefix dir) = do
|
||||||
@ -111,6 +111,12 @@ printMatches w r ms =
|
|||||||
setSGR [SetConsoleIntensity NormalIntensity]
|
setSGR [SetConsoleIntensity NormalIntensity]
|
||||||
putStr $ " " ++ (printf termFormat $ tmTerm m)
|
putStr $ " " ++ (printf termFormat $ tmTerm m)
|
||||||
setSGR [Reset]
|
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 [SetColor Foreground Dull Cyan]
|
||||||
setSGR [SetConsoleIntensity FaintIntensity]
|
setSGR [SetConsoleIntensity FaintIntensity]
|
||||||
putStr $ " " ++ tmPath m
|
putStr $ " " ++ tmPath m
|
||||||
@ -118,6 +124,7 @@ printMatches w r ms =
|
|||||||
putStr "\n"
|
putStr "\n"
|
||||||
where
|
where
|
||||||
termFormat = "%-" ++ (show w) ++ "s"
|
termFormat = "%-" ++ (show w) ++ "s"
|
||||||
|
printNumber = printf "%2d"
|
||||||
|
|
||||||
printParseError :: ParseError -> IO ()
|
printParseError :: ParseError -> IO ()
|
||||||
printParseError e = do
|
printParseError e = do
|
||||||
|
Loading…
Reference in New Issue
Block a user