mirror of
https://github.com/vbatts/git-validation.git
synced 2024-12-28 08:16:31 +00:00
main: adding a quiet flag to reduce the output
so you can test and just check return code Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
eba7575f7e
commit
769b4028a4
2 changed files with 14 additions and 2 deletions
4
main.go
4
main.go
|
@ -17,6 +17,7 @@ var (
|
|||
flRun = flag.String("run", "", "comma delimited list of rules to run. Defaults to all.")
|
||||
flVerbose = flag.Bool("v", false, "verbose")
|
||||
flDebug = flag.Bool("D", false, "debug output")
|
||||
flQuiet = flag.Bool("q", false, "less output")
|
||||
flDir = flag.String("d", ".", "git directory to validate from")
|
||||
)
|
||||
|
||||
|
@ -26,6 +27,9 @@ func main() {
|
|||
if *flDebug {
|
||||
os.Setenv("DEBUG", "1")
|
||||
}
|
||||
if *flQuiet {
|
||||
os.Setenv("QUIET", "1")
|
||||
}
|
||||
|
||||
if *flListRules {
|
||||
for _, r := range validate.RegisteredRules {
|
||||
|
|
|
@ -70,10 +70,18 @@ func (r *Runner) Run() error {
|
|||
|
||||
// run them and show results
|
||||
for _, commit := range c {
|
||||
fmt.Printf(" * %s %q ... ", commit["abbreviated_commit"], commit["subject"])
|
||||
if os.Getenv("QUIET") == "" {
|
||||
fmt.Printf(" * %s %q ... ", commit["abbreviated_commit"], commit["subject"])
|
||||
}
|
||||
vr := Commit(commit, r.Rules)
|
||||
r.Results = append(r.Results, vr...)
|
||||
if _, fail := vr.PassFail(); fail == 0 {
|
||||
_, fail := vr.PassFail()
|
||||
if os.Getenv("QUIET") != "" {
|
||||
// everything else in the loop is printing output.
|
||||
// If we're quiet, then just continue
|
||||
continue
|
||||
}
|
||||
if fail == 0 {
|
||||
fmt.Println("PASS")
|
||||
} else {
|
||||
fmt.Println("FAIL")
|
||||
|
|
Loading…
Reference in a new issue