Skip to content

Commit

Permalink
Removing noColor option (#73)
Browse files Browse the repository at this point in the history
💥
  • Loading branch information
zendern authored Feb 27, 2020
1 parent 225700a commit e5ac27c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ Options:
provides help text on how to use nancy
-no-color
indicate output should not be colorized
-noColor
indicate output should not be colorized (deprecated: please use no-color)
-output string
Styling for output format. ["json-pretty" "text" "csv" "json"] (default "text")
-quiet
Expand Down
9 changes: 0 additions & 9 deletions configuration/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func Parse(args []string) (Configuration, error) {
config := Configuration{}
var excludeVulnerabilityFilePath string
var outputFormat string
var noColorDeprecated bool

var outputFormats = map[string]logrus.Formatter{
"json": &audit.JsonFormatter{},
Expand All @@ -43,7 +42,6 @@ func Parse(args []string) (Configuration, error) {

flag.BoolVar(&config.Help, "help", false, "provides help text on how to use nancy")
flag.BoolVar(&config.NoColor, "no-color", false, "indicate output should not be colorized")
flag.BoolVar(&noColorDeprecated, "noColor", false, "indicate output should not be colorized (deprecated: please use no-color)")
flag.BoolVar(&config.Quiet, "quiet", false, "indicate output should contain only packages with vulnerabilities")
flag.BoolVar(&config.Version, "version", false, "prints current nancy version")
flag.BoolVar(&config.CleanCache, "clean-cache", false, "Deletes local cache directory")
Expand All @@ -69,13 +67,6 @@ func Parse(args []string) (Configuration, error) {
config.Path = args[len(args)-1]
}

if noColorDeprecated == true {
fmt.Println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
fmt.Println("!!!! DEPRECATION WARNING : Please change 'noColor' param to be 'no-color'. This one will be removed in a future release. !!!!")
fmt.Println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
config.NoColor = noColorDeprecated
}

if outputFormats[outputFormat] != nil {
config.Formatter = outputFormats[outputFormat]
} else {
Expand Down
15 changes: 7 additions & 8 deletions configuration/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,13 @@ CVN-543`)
expectedConfig Configuration
expectedErr error
}{
"defaults": {args: []string{"/tmp/go.sum"}, expectedConfig: Configuration{NoColor: false, Quiet: false, Version: false, CveList: types.CveListFlag{}, Formatter: &audit.AuditLogTextFormatter{}, Path: "/tmp/go.sum"}, expectedErr: nil},
"help": {args: []string{"-help", "/tmp/go2.sum"}, expectedConfig: Configuration{Help: true, NoColor: false, Quiet: false, Version: false, CveList: types.CveListFlag{}, Formatter: &audit.AuditLogTextFormatter{}, Path: "/tmp/go2.sum"}, expectedErr: nil},
"no color": {args: []string{"-no-color", "/tmp/go2.sum"}, expectedConfig: Configuration{NoColor: true, Quiet: false, Version: false, CveList: types.CveListFlag{}, Formatter: &audit.AuditLogTextFormatter{}, Path: "/tmp/go2.sum"}, expectedErr: nil},
"no color (deprecated)": {args: []string{"-noColor", "/tmp/go2.sum"}, expectedConfig: Configuration{NoColor: true, Quiet: false, Version: false, CveList: types.CveListFlag{}, Formatter: &audit.AuditLogTextFormatter{}, Path: "/tmp/go2.sum"}, expectedErr: nil},
"quiet": {args: []string{"-quiet", "/tmp/go3.sum"}, expectedConfig: Configuration{NoColor: false, Quiet: true, Version: false, CveList: types.CveListFlag{}, Formatter: &audit.AuditLogTextFormatter{}, Path: "/tmp/go3.sum"}, expectedErr: nil},
"version": {args: []string{"-version", "/tmp/go4.sum"}, expectedConfig: Configuration{NoColor: false, Quiet: false, Version: true, CveList: types.CveListFlag{}, Formatter: &audit.AuditLogTextFormatter{}, Path: "/tmp/go4.sum"}, expectedErr: nil},
"exclude vulnerabilities": {args: []string{"-exclude-vulnerability=CVE123,CVE988", "/tmp/go5.sum"}, expectedConfig: Configuration{NoColor: false, Quiet: false, Version: false, CveList: types.CveListFlag{Cves: []string{"CVE123", "CVE988"}}, Formatter: &audit.AuditLogTextFormatter{}, Path: "/tmp/go5.sum"}, expectedErr: nil},
"std in as input": {args: []string{}, expectedConfig: Configuration{UseStdIn: true, Formatter: &audit.AuditLogTextFormatter{}}, expectedErr: nil},
"defaults": {args: []string{"/tmp/go.sum"}, expectedConfig: Configuration{NoColor: false, Quiet: false, Version: false, CveList: types.CveListFlag{}, Path: "/tmp/go.sum"}, expectedErr: nil},
"help": {args: []string{"-help", "/tmp/go2.sum"}, expectedConfig: Configuration{Help: true, NoColor: false, Quiet: false, Version: false, CveList: types.CveListFlag{}, Path: "/tmp/go2.sum"}, expectedErr: nil},
"no color": {args: []string{"-no-color", "/tmp/go2.sum"}, expectedConfig: Configuration{NoColor: true, Quiet: false, Version: false, CveList: types.CveListFlag{}, Path: "/tmp/go2.sum"}, expectedErr: nil},
"quiet": {args: []string{"-quiet", "/tmp/go3.sum"}, expectedConfig: Configuration{NoColor: false, Quiet: true, Version: false, CveList: types.CveListFlag{}, Path: "/tmp/go3.sum"}, expectedErr: nil},
"version": {args: []string{"-version", "/tmp/go4.sum"}, expectedConfig: Configuration{NoColor: false, Quiet: false, Version: true, CveList: types.CveListFlag{}, Path: "/tmp/go4.sum"}, expectedErr: nil},
"exclude vulnerabilities": {args: []string{"-exclude-vulnerability=CVE123,CVE988", "/tmp/go5.sum"}, expectedConfig: Configuration{NoColor: false, Quiet: false, Version: false, CveList: types.CveListFlag{Cves: []string{"CVE123", "CVE988"}}, Path: "/tmp/go5.sum"}, expectedErr: nil},
"std in as input": {args: []string{}, expectedConfig: Configuration{UseStdIn: true}, expectedErr: nil},
"path but invalid arg": {args: []string{"-invalid", "/tmp/go6.sum"}, expectedConfig: Configuration{}, expectedErr: errors.New("flag provided but not defined: -invalid")},
"exclude vulnerabilities when has comments": {args: []string{"-exclude-vulnerability-file=" + commentedFile.Name(), "/tmp/go14.sum"}, expectedConfig: Configuration{CveList: types.CveListFlag{Cves: []string{"CVN-111", "CVN-123", "CVN-543"}}, Formatter: &audit.AuditLogTextFormatter{}, Path: "/tmp/go14.sum"}, expectedErr: nil},
"exclude vulnerabilities with sane file": {args: []string{"-exclude-vulnerability-file=" + file.Name(), "/tmp/go7.sum"}, expectedConfig: Configuration{CveList: types.CveListFlag{Cves: []string{"CVF-000", "CVF-123", "CVF-9999"}}, Formatter: &audit.AuditLogTextFormatter{}, Path: "/tmp/go7.sum"}, expectedErr: nil},
Expand Down

0 comments on commit e5ac27c

Please sign in to comment.