Skip to content

Commit

Permalink
Simplify output
Browse files Browse the repository at this point in the history
  • Loading branch information
caitlinelfring committed Aug 26, 2020
1 parent 4719145 commit 378a137
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,24 @@ Provide a list file globs for files you'd like to check.`,
} else {
results = p.Parse(args, ignorer)
}
for _, fr := range results {
cmd.Println(fr.String())
}

// cmd.Println(results.OutputString(output))
if len(results) > 0 {
for _, fr := range results {
cmd.Println(fr.String())
}

if exitOneOnFailure {
// We intentionally return an error if exitOneOnFailure is true, but don't want to show usage
cmd.SilenceUsage = true
err = fmt.Errorf("Total failures: %d", len(results))
}
}

if len(results) == 0 {
log.Info().Msg("👏 Great work using inclusive language in your code! Stay woke! 🙌")
}

if len(results) > 0 && exitOneOnFailure {
// We intentionally return an error if exitOneOnFailure is true, but don't want to show usage
cmd.SilenceUsage = true
return fmt.Errorf("Total failures: %d", len(results))
}
return nil
return err
},
}

Expand All @@ -122,7 +124,7 @@ func init() {
rootCmd.Version = getVersion("short")

rootCmd.PersistentFlags().StringVarP(&ruleConfig, "config", "c", "", "YAML file with list of rules")
rootCmd.PersistentFlags().BoolVar(&exitOneOnFailure, "exit-1-on-failure", false, "Exit with exit code 1 on failures. Otherwise, will always exit 0 if any failures occur")
rootCmd.PersistentFlags().BoolVar(&exitOneOnFailure, "exit-1-on-failure", false, "Exit with exit code 1 on failures")
rootCmd.PersistentFlags().BoolVar(&stdin, "stdin", false, "Read from stdin")
rootCmd.PersistentFlags().BoolVar(&debug, "debug", false, "Enable debug logging")
}
Expand Down

0 comments on commit 378a137

Please sign in to comment.