Remove columns displaying occurrence/file count

These columns were not well-explained and, with limited space for
headers, often led to confusion.

This removes the columns. The data is still displayed in the more
verbose output (currently visible when seeing corresponding commit SHAs,
via the `--commits #` flag).

Closes #60
This commit is contained in:
Joshua Clayton 2016-08-31 06:54:57 -04:00
parent 7d9c923bd1
commit 3c3e479e45
No known key found for this signature in database
GPG Key ID: 5B6558F77E9A8118
2 changed files with 3 additions and 24 deletions

View File

@ -4,17 +4,16 @@ module Unused.CLI.Views.SearchResult.ColumnFormatter
) where ) where
import Text.Printf (printf) import Text.Printf (printf)
import Unused.Types (TermResults(..), TermMatch(..), totalFileCount, totalOccurrenceCount) import Unused.Types (TermResults(..), TermMatch(..))
data ColumnFormat = ColumnFormat data ColumnFormat = ColumnFormat
{ cfPrintTerm :: String -> String { cfPrintTerm :: String -> String
, cfPrintPath :: String -> String , cfPrintPath :: String -> String
, cfPrintNumber :: Int -> String
} }
buildColumnFormatter :: [TermResults] -> ColumnFormat buildColumnFormatter :: [TermResults] -> ColumnFormat
buildColumnFormatter r = buildColumnFormatter r =
ColumnFormat (printf $ termFormat r) (printf $ pathFormat r) (printf $ numberFormat r) ColumnFormat (printf $ termFormat r) (printf $ pathFormat r)
termFormat :: [TermResults] -> String termFormat :: [TermResults] -> String
termFormat rs = termFormat rs =
@ -29,17 +28,3 @@ pathFormat rs =
where where
pathWidth = maximum $ pathLength =<< trMatches =<< rs pathWidth = maximum $ pathLength =<< trMatches =<< rs
pathLength = return . length . tmPath pathLength = return . length . tmPath
numberFormat :: [TermResults] -> String
numberFormat rs =
"%" ++ show numberWidth ++ "d"
where
numberWidth = maximum [fileWidth, occurrenceWidth]
fileWidth = maximum $ fileLength =<< rs
occurrenceWidth = maximum $ occurrenceLength =<< rs
fileLength = return . numberLength . totalFileCount
occurrenceLength = return . numberLength . totalOccurrenceCount
numberLength :: Int -> Int
numberLength i =
1 + floor (logBase 10 $ fromIntegral i :: Double)

View File

@ -6,14 +6,13 @@ import Control.Monad (forM_)
import Unused.CLI.Util import Unused.CLI.Util
import qualified Unused.CLI.Views.SearchResult.Internal as SR import qualified Unused.CLI.Views.SearchResult.Internal as SR
import qualified Unused.CLI.Views.SearchResult.Types as SR import qualified Unused.CLI.Views.SearchResult.Types as SR
import Unused.Types (TermResults, TermMatch(..), tmDisplayTerm, totalFileCount, totalOccurrenceCount) import Unused.Types (TermResults, TermMatch(..), tmDisplayTerm)
printTable :: TermResults -> [TermMatch] -> SR.ResultsPrinter () printTable :: TermResults -> [TermMatch] -> SR.ResultsPrinter ()
printTable r ms = do printTable r ms = do
cf <- SR.columnFormat cf <- SR.columnFormat
let printTerm = SR.cfPrintTerm cf let printTerm = SR.cfPrintTerm cf
let printPath = SR.cfPrintPath cf let printPath = SR.cfPrintPath cf
let printNumber = SR.cfPrintNumber cf
SR.liftIO $ forM_ ms $ \m -> do SR.liftIO $ forM_ ms $ \m -> do
setSGR [SetColor Foreground Dull (SR.termColor r)] setSGR [SetColor Foreground Dull (SR.termColor r)]
@ -21,11 +20,6 @@ printTable r ms = do
putStr $ " " ++ printTerm (tmDisplayTerm m) putStr $ " " ++ printTerm (tmDisplayTerm m)
setSGR [Reset] setSGR [Reset]
setSGR [SetColor Foreground Vivid Cyan]
setSGR [SetConsoleIntensity NormalIntensity]
putStr $ " " ++ printNumber (totalFileCount r) ++ ", " ++ printNumber (totalOccurrenceCount r)
setSGR [Reset]
setSGR [SetColor Foreground Dull Cyan] setSGR [SetColor Foreground Dull Cyan]
setSGR [SetConsoleIntensity FaintIntensity] setSGR [SetConsoleIntensity FaintIntensity]
putStr $ " " ++ printPath (tmPath m) putStr $ " " ++ printPath (tmPath m)