Documentation
¶
Overview ¶
Package root defines the root configuration for the CLI.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUsage = errors.New("invalid usage")
ErrUsage matches any usage error through errors.Is: a missing or malformed argument, an unknown flag or subcommand, conflicting flags. The dispatcher prints the selected command's help only for errors that match ErrUsage (and for --help), so a runtime failure is reported without a screenful of help above it, and main exits 2 for them where other failures exit 1. For the details, recover *UsageError with errors.AsType.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
Flags *ff.FlagSet
Command *ff.Command
// Options are where the measurement reads its inputs, bound to the
// flags; their methods (Load, GateInput, ReadBaseline, ...) are the
// commands' shared shell.
pipeline.Options
// Format is "text" or "json".
Format string
}
Config holds shared I/O writers, the analysis flags every measuring command shares, and the root ff.Command. All subcommand configs embed *Config to inherit these.
func (*Config) SARIFOptions ¶
SARIFOptions are what check's SARIF log records besides the result: the tool's version, and the model file relative to --dir.
type ExitError ¶
type ExitError int
ExitError is returned by commands that want a specific non-zero exit code without printing an additional error message. run() in main.go checks for ExitError with errors.As and calls os.Exit(int(e)) directly, bypassing the default "error: ..." printer.
const ErrGateFailed ExitError = 3
ErrGateFailed exits with the status of a check whose gate failed: distinct from 1, a run that could not measure, and 2, a usage error, so CI can tell an architecture regression from a broken pipeline.
type UsageError ¶
type UsageError struct {
Err error
}
UsageError reports that the command line, not the work it asked for, was wrong. Err says what was wrong, e.g. "add: command name required"; its text is the whole message. A command's exec returns one as
return &UsageError{Err: fmt.Errorf("add: --name: %w", err)}
building Err with errors.New or fmt.Errorf, whose %w keeps a cause inspectable.
func (*UsageError) Error ¶
func (e *UsageError) Error() string
func (*UsageError) Is ¶
func (e *UsageError) Is(target error) bool
Is reports whether target is ErrUsage.
func (*UsageError) Unwrap ¶
func (e *UsageError) Unwrap() error
Unwrap returns the cause, so errors.Is and errors.As see through to it.