config

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const KeyJSON = "json"

KeyJSON is the json flag name.

View Source
const KeyModel = "model"

KeyModel is the model flag name.

View Source
const KeyPretty = "pretty"

KeyPretty is the pretty flag name.

View Source
const KeyProfile = "profile"

KeyProfile is the profile flag name.

View Source
const KeyRewrite = "rewrite"

KeyRewrite is the rewrite flag name.

View Source
const KeyWrite = "write"

KeyWrite is the write flag name.

Variables

View Source
var DefaultJSON = false

DefaultJSON is false, meaning text output.

View Source
var DefaultModel = rewrite.DefaultModel

DefaultModel is the model the rewrite pass uses when none is set.

View Source
var DefaultPretty = false

DefaultPretty is false, meaning compact JSON.

View Source
var DefaultProfile = ""

DefaultProfile is empty, meaning the built-in profile.

View Source
var DefaultRewrite = false

DefaultRewrite is false, meaning rules only.

View Source
var DefaultWrite = false

DefaultWrite is false, meaning results go to stdout.

View Source
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.

View Source
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.

View Source
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.

View Source
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.

View Source
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.

View Source
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 Changed

func Changed(key string) bool

Changed reports whether the flag for key was set on the command line.

func JSON

func JSON() bool

JSON reports whether stdout should carry JSON.

func Model

func Model() string

Model returns the model id for the rewrite pass.

func Pretty

func Pretty() bool

Pretty reports whether JSON output should be indented.

func Profile

func Profile() string

Profile returns the configured profile path, or empty for the built-in profile.

func Reset

func Reset()

Reset puts every flag back to its default. Tests use it between command runs because flag state is shared package-wide.

func Rewrite

func Rewrite() bool

Rewrite reports whether the model rewrite pass should run.

func Write

func Write() bool

Write reports whether results should be written back to their files.

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.

func (*FlagValue) Set

func (v *FlagValue) Set(s string) error

Set validates s against the value type and stores it.

func (*FlagValue) String

func (v *FlagValue) String() string

String returns the current raw value.

func (*FlagValue) Type

func (v *FlagValue) Type() string

Type returns the pflag type name.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL