@@ -10,12 +10,12 @@ import (
1010 "slices"
1111 "strings"
1212
13- "github.com/fatih/color"
1413 "github.com/g-rath/osv-detector/internal"
1514 "github.com/g-rath/osv-detector/internal/configer"
1615 "github.com/g-rath/osv-detector/internal/reporter"
1716 "github.com/g-rath/osv-detector/pkg/database"
1817 "github.com/g-rath/osv-detector/pkg/lockfile"
18+ "github.com/jedib0t/go-pretty/v6/text"
1919)
2020
2121// these come from goreleaser
@@ -91,11 +91,11 @@ func (dbs OSVDatabases) check(r *reporter.Reporter, lockf lockfile.Lockfile, ign
9191 results , err := db .Check (lockf .Packages )
9292
9393 if err != nil {
94- r .PrintErrorf ("%s" , color . RedString ( fmt .Sprintf (
94+ r .PrintErrorf ("%s" , text . FgRed .Sprintf (
9595 " an api error occurred while trying to check the packages listed in %s: %v\n " ,
9696 lockf .FilePath ,
9797 err ,
98- )))
98+ ))
9999
100100 continue
101101 }
@@ -160,13 +160,13 @@ func uniqueDBConfigs(configs []*configer.Config) []database.Config {
160160func describeDB (db database.DB ) string {
161161 switch tt := db .(type ) {
162162 case * database.APIDB :
163- return "using batches of " + color . YellowString ("%d" , tt .BatchSize )
163+ return "using batches of " + text . FgYellow . Sprintf ("%d" , tt .BatchSize )
164164 case * database.ZipDB :
165165 count := tt .VulnerabilitiesCount
166166
167167 return fmt .Sprintf (
168168 "%s %s, including withdrawn - last updated %s" ,
169- color . YellowString ("%d" , count ),
169+ text . FgYellow . Sprintf ("%d" , count ),
170170 reporter .Form (count , "vulnerability" , "vulnerabilities" ),
171171 tt .UpdatedAt ,
172172 )
@@ -175,7 +175,7 @@ func describeDB(db database.DB) string {
175175
176176 return fmt .Sprintf (
177177 "%s %s, including withdrawn" ,
178- color . YellowString ("%d" , count ),
178+ text . FgYellow . Sprintf ("%d" , count ),
179179 reporter .Form (count , "vulnerability" , "vulnerabilities" ),
180180 )
181181 }
@@ -644,8 +644,8 @@ This flag can be passed multiple times to ignore different vulnerabilities`)
644644
645645 r .PrintTextf (
646646 "%s: found %s %s\n " ,
647- color . MagentaString ( "%s" , lockf .FilePath ),
648- color . YellowString ("%d" , len (lockf .Packages )),
647+ text . FgMagenta . Sprint ( lockf .FilePath ),
648+ text . FgYellow . Sprintf ("%d" , len (lockf .Packages )),
649649 reporter .Form (len (lockf .Packages ), "package" , "packages" ),
650650 )
651651
@@ -670,15 +670,15 @@ This flag can be passed multiple times to ignore different vulnerabilities`)
670670 ignoresStr = "skipping any ignores"
671671 } else {
672672 ignores = append (ignores , config .Ignore ... )
673- ignoresStr = color . YellowString ("%d %s" ,
673+ ignoresStr = text . FgYellow . Sprintf ("%d %s" ,
674674 len (config .Ignore ),
675675 reporter .Form (len (config .Ignore ), "ignore" , "ignores" ),
676676 )
677677 }
678678
679679 r .PrintTextf (
680680 " Using config at %s (%s)\n " ,
681- color . MagentaString (config .FilePath ),
681+ text . FgMagenta . Sprint (config .FilePath ),
682682 ignoresStr ,
683683 )
684684 }
@@ -695,7 +695,7 @@ This flag can be passed multiple times to ignore different vulnerabilities`)
695695
696696 r .PrintTextf (
697697 " Using db %s%s\n " ,
698- color . HiCyanString (db .Name ()),
698+ text . FgHiCyan . Sprint (db .Name ()),
699699 desc ,
700700 )
701701 }
@@ -760,7 +760,7 @@ func writeUpdatedConfigs(r *reporter.Reporter, vulnsPerConfig map[string]map[str
760760 if err == nil {
761761 lines = append (lines , fmt .Sprintf (
762762 "Updated %s with %d %s\n " ,
763- color . MagentaString (configPath ),
763+ text . FgMagenta . Sprint (configPath ),
764764 len (vulns ),
765765 reporter .Form (len (vulns ), "vulnerability" , "vulnerabilities" ),
766766 ))
0 commit comments