Files
releases/cmd/flags.go
T
Torin Sandall eabe7f1312 cmd: Update subcommands to support fails explanation mode
This change updates the test command to use the fail explanation mode
by default. Since the test framework expects test rules to be
defined/true failure events are usually what is required to debug test
failures (e.g., some assertion in the test rule will Fail and that
will _likely_ be based on some failure in the policy under test.)
Hopefully this makes the test output a bit less verbose and more readable.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-07-29 18:56:09 -04:00

35 lines
1.0 KiB
Go

// Copyright 2017 The OPA Authors. All rights reserved.
// Use of this source code is governed by an Apache2
// license that can be found in the LICENSE file.
package cmd
import (
"github.com/open-policy-agent/opa/ast"
"github.com/open-policy-agent/opa/util"
"github.com/spf13/pflag"
)
func setMaxErrors(fs *pflag.FlagSet, errLimit *int) {
fs.IntVarP(errLimit, "max-errors", "m", ast.CompileErrorLimitDefault, "set the number of errors to allow before compilation fails early")
}
func setIgnore(fs *pflag.FlagSet, ignoreNames *[]string) {
fs.StringSliceVarP(ignoreNames, "ignore", "", []string{}, "set file and directory names to ignore during loading (e.g., '.*' excludes hidden files)")
}
const (
explainModeOff = "off"
explainModeFull = "full"
explainModeNotes = "notes"
explainModeFails = "fails"
)
func newExplainFlag(modes []string) *util.EnumFlag {
return util.NewEnumFlag(modes[0], modes)
}
func setExplain(fs *pflag.FlagSet, explain *util.EnumFlag) {
fs.VarP(explain, "explain", "", "enable query explanations")
}