config

package
v0.36.4 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package config holds the CLI configuration.

Index

Constants

View Source
const (
	// ColorAuto enables colorized diagnostic output on a tty only.
	ColorAuto = "auto"

	// ColorAlways colorized diagnostic output without checking for a terminal.
	ColorAlways = "always"

	// ColorNever disables colorized diagnostic output.
	ColorNever = "never"
)

What -color can be told. "auto" is the only one that looks at where it is writing.

View Source
const (
	FailNever   = "never"
	FailError   = "error"
	FailWarning = "warning"
)

What -fail-on can be told: the least serious diagnostic that still makes the command exit non-zero.

"never" is the default because a scan that emits warnings is the ordinary case - a codebase with nothing to say about it is the exception - and a command that failed the build over one would mostly teach people to stop reading it.

View Source
const (
	FormatAuto = "auto"
	FormatJSON = "json"
	FormatYAML = "yaml"
)

What -format can be told.

"auto" reads the extension of -output, or defaults to JSON, which is what a document going to standard output does.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config is the whole command line: the library's own knobs, plus this command's.

func NewWithFlags

func NewWithFlags(fs *flag.FlagSet, stdout, stderr io.Writer) *Config

func (*Config) Format

func (c *Config) Format() string

func (*Config) Output

func (c *Config) Output() string

func (*Config) PrepareScan

func (c *Config) PrepareScan() (options *scanner.Options, reporter *diagnostics.Reporter, err error)

PrepareScan converts a CLI Config into proper scanner.Options that the scanner understands.

It also prepares a configured diagnostics.Reporter for further reporting about diagnostics. At this point, no downstream consumer needs to know where a value came from (file, env, flag...).

func (*Config) WantsCompactJSON

func (c *Config) WantsCompactJSON() bool

func (*Config) WantsValidation

func (c *Config) WantsValidation() bool

func (*Config) WantsVersion

func (c *Config) WantsVersion() bool

Jump to

Keyboard shortcuts

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