Skip to content

Commit

Permalink
Merge pull request #44 from thushan/show-size-of-duplicates
Browse files Browse the repository at this point in the history
displays duplicate space.
  • Loading branch information
thushan authored Dec 16, 2023
2 parents 100891a + 59288d4 commit 1eed39b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/smash/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@ func displayFiles(files []report.SmashFile) {
if duplicateFiles != 0 {
root := files[0]
dupes := files[1:]
theme.Println(theme.ColourFilename(root.Path), " ", theme.ColourFileSize(root.FileSizeF), " ", theme.ColourHash(root.Hash))
var dupeSize string
if len(files) > 2 {
totalDupeSize := uint64(len(files)-1) * root.FileSize
dupeSize = "(" + theme.ColourFileSizeDupe(humanize.Bytes(totalDupeSize)) + ")"
} else {
dupeSize = " "
}
theme.Println(theme.ColourFilename(root.Path), " ", theme.ColourFileSize(root.FileSizeF), dupeSize, theme.ColourHash(root.Hash))
printSmashHits(dupes)
}
}
Expand Down
3 changes: 3 additions & 0 deletions internal/theme/style.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ func ColourFileSize(message ...any) string {
func ColourFileSizeA(message ...any) string {
return pterm.Cyan(message...)
}
func ColourFileSizeDupe(message ...any) string {
return pterm.LightRed(message...)
}
func ColourHash(message ...any) string {
return pterm.Gray(message...)
}
Expand Down

0 comments on commit 1eed39b

Please sign in to comment.