Documentation
¶
Index ¶
Constants ¶
const ( ExitOK = 0 ExitRuntime = 1 ExitUsage = 2 ExitPartialFailure = 3 )
Exit codes returned by Run. They follow the convention documented in docs/cli-conventions.md:
0 — success 1 — runtime error (default) 2 — usage error (bad flags / args) 3 — partial failure (some operations succeeded, some failed)
Variables ¶
This section is empty.
Functions ¶
func FormatReference ¶
FormatReference renders a Reference as a single human-readable line for the text output of `klim info` and `klim why`. Both surfaces consume this directly so the surrounding wording — and any new Reference.Kind that gets added — stays in lockstep across the two commands. Required + optional refs both preserve their version constraint via roleWithConstraint.
func ResolveVulnSourceKey ¶
func ResolveVulnSourceKey() string
ResolveVulnSourceKey returns the OSV endpoint string used as the cache key for vulnerability scan results. Surfaces that read the cache passively (`klim info`, web `/security`) must use the same key as `klim security vuln`, otherwise they look at a different file. Falls back to vuln.DefaultOSVURL when config is unreadable or the URL is unset.
func Run ¶
func Run() int
Run executes the root command and returns a process exit code.
Exit codes:
0 — success 1 — runtime error 2 — usage error (bad flags, args, or output format) 3 — partial failure (e.g. some imports failed)
Cobra's own flag-parse errors are wrapped in UsageError via SetFlagErrorFunc on rootCmd, and "unknown command" / "unknown flag" errors that escape that hook are detected by message prefix here. All other errors map to ExitRuntime.
Types ¶
type Action ¶
type Action string
Action discriminates the three sibling action commands.
type OutputFormat ¶
type OutputFormat string
OutputFormat names the canonical output formats supported by commands.
AGENTS.md ("CLI Standards"): commands should expose `--output` for machine-readable output. klim adopts `--output={text,json,yaml}` as the canonical flag and keeps `--json` as a deprecated alias for backward compatibility.
const ( OutputText OutputFormat = "text" OutputJSON OutputFormat = "json" OutputYAML OutputFormat = "yaml" )
Output formats accepted by the canonical --output flag.
type PackageEntry ¶
PackageEntry is one populated package-manager ID for a tool. Shared between `klim why` (AvailableVia) and `klim info` (Packages) so the list of supported sources cannot drift between the two commands the next time a package manager is added or renamed.
func CollectPackageEntries ¶
func CollectPackageEntries(pkgs registry.PackageIDs) []PackageEntry
CollectPackageEntries returns the populated PackageEntries for pkgs in canonical display order. Empty IDs are skipped. Both `klim why` and `klim info` consume this so they list the same sources every time.
type PartialFailureError ¶
PartialFailureError signals a multi-item operation where some items succeeded and some failed. Run translates this to ExitPartialFailure.
func (*PartialFailureError) Error ¶
func (e *PartialFailureError) Error() string
type PendingChangesError ¶ added in v0.1.3
PendingChangesError signals a non-failure outcome that should still map to ExitPartialFailure (exit 3). The canonical use case is `klim plan --detailed-exitcode` — there's no failure, but the diff is non-empty and the CI caller asked us to gate on that. Keeping this distinct from PartialFailureError avoids the misleading "0 succeeded, N failed" framing for an outcome that's really "N changes pending".
func (*PendingChangesError) Error ¶ added in v0.1.3
func (e *PendingChangesError) Error() string
type Reference ¶
type Reference struct {
Kind string `yaml:"kind" json:"kind"`
Name string `yaml:"name,omitempty" json:"name,omitempty"`
DisplayName string `yaml:"display_name,omitempty" json:"display_name,omitempty"`
Path string `yaml:"path,omitempty" json:"path,omitempty"`
Required bool `yaml:"required,omitempty" json:"required,omitempty"`
Constraint string `yaml:"version_constraint,omitempty" json:"version_constraint,omitempty"`
}
Reference describes a place where a tool is mentioned: the local .klim.yaml, a registered project's .klim.yaml, a marketplace pack, or a custom pack. It's the shared shape used by both `klim why` and `klim info` so the two commands cannot drift out of sync.
func CollectReferences ¶
CollectReferences scans the four sources where a tool name can appear (CWD-or-ancestor .klim.yaml, registered projects, marketplace packs, custom packs) and returns matched references plus any non-fatal warnings encountered along the way.
Both teamfile parses (local + registered) accumulate parse errors into warnings rather than silently dropping them — otherwise a malformed file could mislead the caller into reporting "no references found" when there really are some.
Pack lookups go through cliCtx via svcFrom(cmd) so tests can stub the service.
type UsageError ¶
type UsageError struct{ Err error }
UsageError signals the user invoked the CLI incorrectly (missing/extra args, unknown flags, malformed input). Run translates this to ExitUsage.
func (*UsageError) Error ¶
func (e *UsageError) Error() string
func (*UsageError) Unwrap ¶
func (e *UsageError) Unwrap() error
Source Files
¶
- action.go
- action_run.go
- apply.go
- audit.go
- browser.go
- check.go
- checkpoint.go
- completion.go
- compliance.go
- config.go
- context.go
- diff.go
- doctor.go
- env.go
- errors.go
- export.go
- generate.go
- health_backups.go
- health_path.go
- help.go
- hook.go
- import.go
- info.go
- init_teamfile.go
- install.go
- installplan.go
- list.go
- marketplace.go
- onboard.go
- open.go
- output.go
- plan.go
- proxy.go
- refscan.go
- remove.go
- rollback.go
- root.go
- score.go
- search.go
- security.go
- share.go
- shell.go
- spinner.go
- tools.go
- trail.go
- try.go
- update.go
- upgrade.go
- version.go
- watch.go
- why.go