configcmd

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 15 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package configcmd implements the `vigolium config` command group.

It is the first command group split out of the flat pkg/cli package into its own subpackage. Rather than self-registering via init() into a package-private rootCmd, it exposes an explicit NewCommand(deps, examples) constructor that pkg/cli wires onto the root command. All of the implicit package-global state the commands previously reached for (the --config / --force flag values and the first-run reinitializer) is passed in explicitly via Deps, so this package has no dependency back on pkg/cli.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBadSetting added in v0.5.7

func IsBadSetting(err error) bool

IsBadSetting reports whether a failed write names no setting or a value that cannot be stored under it (a list that does not parse, a bool that is not true/false, a scope pattern that validation rejects): a mistake on the command line (exit 2), not a failure to write the config. Nothing was written.

func NewCommand

func NewCommand(deps Deps, ex Examples) *cobra.Command

NewCommand builds the `config` command group with its subcommands.

Types

type Deps

type Deps struct {
	// ConfigFlag returns the raw --config flag value (may be empty).
	ConfigFlag func() string
	// Force returns the --force flag value.
	Force func() bool
	// Reinitialize regenerates ~/.vigolium with fresh defaults (used by `config clean`).
	Reinitialize func() error

	// JSON reports whether the caller asked for machine output. The config
	// commands accepted the persistent --json flag and ignored it, printing
	// ANSI-colored prose to stdout and exiting 0 — so a consumer's parse failed
	// for a reason the exit code did not describe.
	JSON func() bool
	// WriteJSON emits a result through the CLI's shared envelope writer, so a
	// config result has the same schema_version/items/generated_at spine as every
	// other -j payload rather than a second shape invented here. total is the row
	// count, which the caller already knows — passing it avoids reflecting over
	// the slice on the other side of the seam. cmd names the document.
	WriteJSON func(cmd *cobra.Command, legacyKey string, items any, total int, extra map[string]any) error
	// WriteMutation emits a state-changing command's result through the CLI's
	// mutation spine (kind "mutation", changed, action, dry_run). changed and
	// action are arguments, not extras: the envelope owns those keys, and an
	// extra named "changed" is dropped rather than rendered.
	WriteMutation func(cmd *cobra.Command, items any, changed bool, action string, extra map[string]any) error
	// WriteDryRunMutation is WriteMutation for a --dry-run: dry_run true and
	// changed false.
	WriteDryRunMutation func(cmd *cobra.Command, items any, action string, extra map[string]any) error

	// RecentScanTargets returns the targets of the n most recent scans in the
	// given project ("" = the project the CLI resolves by default), for
	// `config validate`'s scope_include_matches_no_recent_target rule. Injected
	// because this package cannot reach the database. nil, or an error (no
	// database yet), skips the rule.
	RecentScanTargets func(projectUUID string, n int) ([]string, error)

	// ProjectSettings loads the settings a scan in the invocation's project
	// runs under (global config, then the project overlay) and names that
	// project ("" = no overlay). nil falls back to the global config alone.
	ProjectSettings func() (*config.Settings, string, error)
	// FlagKeys lists the settings keys a global flag of this invocation sets
	// (--db → database.sqlite.path), for the provenance column.
	FlagKeys func() []string
}

Deps carries the runtime dependencies the config commands need, injected by pkg/cli so this package stays decoupled from the CLI's global flag state.

type EntryView added in v0.5.7

type EntryView struct {
	Key       string `json:"key"`
	Value     any    `json:"value"`
	Display   string `json:"display"`
	Default   any    `json:"default"`
	Type      string `json:"type"`
	Source    string `json:"source"`
	Sensitive bool   `json:"sensitive"`
	Empty     bool   `json:"empty"`
	Redacted  bool   `json:"redacted"`
}

EntryView is one setting in the shape a machine consumer reads.

Value is typed (bool, number, string, list, object) and REDACTED under the default policy when the key is a string credential; Display is the string the human table prints. `sensitive` is carried so a consumer can tell a genuinely empty setting from one that was withheld.

type EnvView added in v0.5.7

type EnvView struct {
	Name         string `json:"name"`
	Set          bool   `json:"set"`
	Value        string `json:"value,omitempty"`
	Redacted     bool   `json:"redacted"`
	Sensitive    bool   `json:"sensitive"`
	OverridesKey string `json:"overrides_key,omitempty"`
	Template     bool   `json:"template,omitempty"`
	Description  string `json:"description"`
}

EnvView is one `config env` row.

type Examples

type Examples struct {
	Parent   string
	Ls       string
	Set      string
	Clean    string
	Validate string
}

Examples carries the per-command example blocks, defined in pkg/cli.

type UnsetResult added in v0.5.7

type UnsetResult struct {
	Key        string `json:"key"`
	Removed    bool   `json:"removed"`
	ConfigPath string `json:"config_path"`
}

UnsetResult is the `config unset -j` row.

Jump to

Keyboard shortcuts

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