@@ -10,12 +10,12 @@ import (
1010 "sort"
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
@@ -88,11 +88,11 @@ func (dbs OSVDatabases) check(r *reporter.Reporter, lockf lockfile.Lockfile, ign
8888 results , err := db .Check (lockf .Packages )
8989
9090 if err != nil {
91- r .PrintErrorf (color . RedString ( fmt .Sprintf (
91+ r .PrintErrorf (text . FgRed .Sprintf (
9292 " an api error occurred while trying to check the packages listed in %s: %v\n " ,
9393 lockf .FilePath ,
9494 err ,
95- )))
95+ ))
9696
9797 continue
9898 }
@@ -157,13 +157,13 @@ func uniqueDBConfigs(configs []*configer.Config) []database.Config {
157157func describeDB (db database.DB ) string {
158158 switch tt := db .(type ) {
159159 case * database.APIDB :
160- return "using batches of " + color . YellowString ("%d" , tt .BatchSize )
160+ return "using batches of " + text . FgYellow . Sprintf ("%d" , tt .BatchSize )
161161 case * database.ZipDB :
162162 count := tt .VulnerabilitiesCount
163163
164164 return fmt .Sprintf (
165165 "%s %s, including withdrawn - last updated %s" ,
166- color . YellowString ("%d" , count ),
166+ text . FgYellow . Sprintf ("%d" , count ),
167167 reporter .Form (count , "vulnerability" , "vulnerabilities" ),
168168 tt .UpdatedAt ,
169169 )
@@ -172,7 +172,7 @@ func describeDB(db database.DB) string {
172172
173173 return fmt .Sprintf (
174174 "%s %s, including withdrawn" ,
175- color . YellowString ("%d" , count ),
175+ text . FgYellow . Sprintf ("%d" , count ),
176176 reporter .Form (count , "vulnerability" , "vulnerabilities" ),
177177 )
178178 }
@@ -626,8 +626,8 @@ This flag can be passed multiple times to ignore different vulnerabilities`)
626626
627627 r .PrintTextf (
628628 "%s: found %s %s\n " ,
629- color . MagentaString ( "%s" , lockf .FilePath ),
630- color . YellowString ("%d" , len (lockf .Packages )),
629+ text . FgMagenta . Sprintf ( lockf .FilePath ),
630+ text . FgYellow . Sprintf ("%d" , len (lockf .Packages )),
631631 reporter .Form (len (lockf .Packages ), "package" , "packages" ),
632632 )
633633
@@ -652,15 +652,15 @@ This flag can be passed multiple times to ignore different vulnerabilities`)
652652 ignoresStr = "skipping any ignores"
653653 } else {
654654 ignores = append (ignores , config .Ignore ... )
655- ignoresStr = color . YellowString ("%d %s" ,
655+ ignoresStr = text . FgYellow . Sprintf ("%d %s" ,
656656 len (config .Ignore ),
657657 reporter .Form (len (config .Ignore ), "ignore" , "ignores" ),
658658 )
659659 }
660660
661661 r .PrintTextf (
662662 " Using config at %s (%s)\n " ,
663- color . MagentaString (config .FilePath ),
663+ text . FgMagenta . Sprintf (config .FilePath ),
664664 ignoresStr ,
665665 )
666666 }
@@ -677,7 +677,7 @@ This flag can be passed multiple times to ignore different vulnerabilities`)
677677
678678 r .PrintTextf (
679679 " Using db %s%s\n " ,
680- color . HiCyanString (db .Name ()),
680+ text . FgHiCyan . Sprintf (db .Name ()),
681681 desc ,
682682 )
683683 }
@@ -740,7 +740,7 @@ func writeUpdatedConfigs(r *reporter.Reporter, vulnsPerConfig map[string]map[str
740740 if err == nil {
741741 lines = append (lines , fmt .Sprintf (
742742 "Updated %s with %d %s\n " ,
743- color . MagentaString (configPath ),
743+ text . FgMagenta . Sprintf (configPath ),
744744 len (vulns ),
745745 reporter .Form (len (vulns ), "vulnerability" , "vulnerabilities" ),
746746 ))
0 commit comments