Skip to content

Commit d35da62

Browse files
justinTMgouthamve
andauthored
Add rules diff verbosity flag (#199)
* add rules diff verbosity flag * Make the deleted lines - Signed-off-by: Goutham Veeramachaneni <[email protected]> Co-authored-by: Justin Mai <[email protected]> Co-authored-by: Goutham Veeramachaneni <[email protected]>
1 parent e0839f0 commit d35da62

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

pkg/commands/rules.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ type RuleCommand struct {
8282
Format string
8383

8484
DisableColor bool
85+
86+
// Diff Rules Config
87+
Verbose bool
8588
}
8689

8790
// Register rule related commands and flags with the kingpin application
@@ -182,6 +185,7 @@ func (r *RuleCommand) Register(app *kingpin.Application) {
182185
"Comma separated list of paths to directories containing rules yaml files. Each file in a directory with a .yml or .yaml suffix will be parsed.",
183186
).StringVar(&r.RuleFilesPath)
184187
diffRulesCmd.Flag("disable-color", "disable colored output").BoolVar(&r.DisableColor)
188+
diffRulesCmd.Flag("verbose", "show diff output with rules changes").BoolVar(&r.Verbose)
185189

186190
// Sync Command
187191
syncRulesCmd.Arg("rule-files", "The rule files to check.").ExistingFilesVar(&r.RuleFilesList)
@@ -489,7 +493,7 @@ func (r *RuleCommand) diffRules(k *kingpin.ParseContext) error {
489493
}
490494

491495
p := printer.New(r.DisableColor)
492-
return p.PrintComparisonResult(changes, false)
496+
return p.PrintComparisonResult(changes, r.Verbose)
493497
}
494498

495499
func (r *RuleCommand) syncRules(k *kingpin.ParseContext) error {

pkg/printer/printer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (p *Printer) PrintComparisonResult(results []rules.NamespaceChange, verbose
161161
oldYaml, _ := yaml.Marshal(c.Original)
162162
separated = strings.Split(string(oldYaml), "\n")
163163
for _, l := range separated {
164-
p.Printf("[red]+ %v\n", l)
164+
p.Printf("[red]- %v\n", l)
165165
}
166166
}
167167
}

0 commit comments

Comments
 (0)