Documentation
¶
Index ¶
Constants ¶
const KeyJSON = "json"
KeyJSON is the json flag name.
const KeyModel = "model"
KeyModel is the model flag name.
const KeyPretty = "pretty"
KeyPretty is the pretty flag name.
const KeyProfile = "profile"
KeyProfile is the profile flag name.
const KeyRewrite = "rewrite"
KeyRewrite is the rewrite flag name.
const KeyWrite = "write"
KeyWrite is the write flag name.
Variables ¶
var DefaultJSON = false
DefaultJSON is false, meaning text output.
var DefaultModel = rewrite.DefaultModel
DefaultModel is the model the rewrite pass uses when none is set.
var DefaultPretty = false
DefaultPretty is false, meaning compact JSON.
var DefaultProfile = ""
DefaultProfile is empty, meaning the built-in profile.
var DefaultRewrite = false
DefaultRewrite is false, meaning rules only.
var DefaultWrite = false
DefaultWrite is false, meaning results go to stdout.
var FlagJSON = pflag.Flag{ Name: KeyJSON, Usage: "Write JSON to stdout (findings for check, result for fix).", Value: &FlagValue{Val: strconv.FormatBool(DefaultJSON), ValType: "bool"}, DefValue: strconv.FormatBool(DefaultJSON), NoOptDefVal: "true", }
FlagJSON switches stdout to JSON: findings for check, the result for fix.
var FlagModel = pflag.Flag{ Name: KeyModel, Usage: "Model for --rewrite (default " + rewrite.DefaultModel + ").", Value: &FlagValue{Val: rewrite.DefaultModel, ValType: "string"}, DefValue: rewrite.DefaultModel, }
FlagModel picks the model for the rewrite pass.
var FlagPretty = pflag.Flag{ Name: KeyPretty, Usage: "Indent the JSON output.", Value: &FlagValue{Val: strconv.FormatBool(DefaultPretty), ValType: "bool"}, DefValue: strconv.FormatBool(DefaultPretty), NoOptDefVal: "true", }
FlagPretty indents the JSON output.
var FlagProfile = pflag.Flag{ Name: KeyProfile, Usage: "Path to a JSON style profile (default: built-in).", Value: &FlagValue{ValType: "string"}, DefValue: DefaultProfile, }
FlagProfile points at a JSON style profile instead of the built-in one.
var FlagRewrite = pflag.Flag{ Name: KeyRewrite, Usage: "Send the rules output to a model for a deeper clean.", Value: &FlagValue{Val: strconv.FormatBool(DefaultRewrite), ValType: "bool"}, DefValue: strconv.FormatBool(DefaultRewrite), NoOptDefVal: "true", }
FlagRewrite runs the model rewrite pass after the rules pass.
var FlagWrite = pflag.Flag{ Name: KeyWrite, Shorthand: "w", Usage: "Write the result back to the file instead of stdout.", Value: &FlagValue{Val: strconv.FormatBool(DefaultWrite), ValType: "bool"}, DefValue: strconv.FormatBool(DefaultWrite), NoOptDefVal: "true", }
FlagWrite saves the result back to each file instead of writing to stdout.
Functions ¶
func Profile ¶
func Profile() string
Profile returns the configured profile path, or empty for the built-in profile.
Types ¶
type FlagValue ¶
type FlagValue struct {
// Val is the current raw value.
Val string
// ValType is the type name pflag shows in help output, like string or bool.
ValType string
}
FlagValue is a pflag.Value backed by a raw string. Every scalar flag in the config package uses it so flag state lives in one shape.