Skip to content

Commit 769b402

Browse files
committed
main: adding a quiet flag to reduce the output
so you can test and just check return code Signed-off-by: Vincent Batts <[email protected]>
1 parent eba7575 commit 769b402

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ var (
1717
flRun = flag.String("run", "", "comma delimited list of rules to run. Defaults to all.")
1818
flVerbose = flag.Bool("v", false, "verbose")
1919
flDebug = flag.Bool("D", false, "debug output")
20+
flQuiet = flag.Bool("q", false, "less output")
2021
flDir = flag.String("d", ".", "git directory to validate from")
2122
)
2223

@@ -26,6 +27,9 @@ func main() {
2627
if *flDebug {
2728
os.Setenv("DEBUG", "1")
2829
}
30+
if *flQuiet {
31+
os.Setenv("QUIET", "1")
32+
}
2933

3034
if *flListRules {
3135
for _, r := range validate.RegisteredRules {

validate/runner.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,18 @@ func (r *Runner) Run() error {
7070

7171
// run them and show results
7272
for _, commit := range c {
73-
fmt.Printf(" * %s %q ... ", commit["abbreviated_commit"], commit["subject"])
73+
if os.Getenv("QUIET") == "" {
74+
fmt.Printf(" * %s %q ... ", commit["abbreviated_commit"], commit["subject"])
75+
}
7476
vr := Commit(commit, r.Rules)
7577
r.Results = append(r.Results, vr...)
76-
if _, fail := vr.PassFail(); fail == 0 {
78+
_, fail := vr.PassFail()
79+
if os.Getenv("QUIET") != "" {
80+
// everything else in the loop is printing output.
81+
// If we're quiet, then just continue
82+
continue
83+
}
84+
if fail == 0 {
7785
fmt.Println("PASS")
7886
} else {
7987
fmt.Println("FAIL")

0 commit comments

Comments
 (0)