configcmd and version: the config and version standard commands; darwin /var/run

core/configcmd: "<program> config create|validate|upgrade|path" from a
Spec (name, application, minimal/full templates, Validate, Schema),
taken over from yamase-core/pkg/configcmd and generalized: Filename,
Optional (programs that run on defaults) and None (no configuration).

core/version: "<program> version [--json]" over the values each
program stamps into its internal/version; JSON keys match yasta's
existing output (yavebu reads it), VCS fallback for unstamped builds.

paths: macOS CLI/Service system-scope RuntimeDir is /var/run/<app>
instead of /run/<app>, which macOS does not have.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
terminarandClaude Opus 5.5 committed 2026-10-23 14:36:48 +02:00
1 parent ca0f06f978
commit 90132e2d76
13 files changed
+1824 -20

No files matched your search

+50 -3
View File
@@ -6,8 +6,12 @@ and platform integration -- not just a grab-bag of utility functions (see
`AGENTS.md` in the meta-repository root, and [ARCHITECTURE.md](ARCHITECTURE.md)
for the full design rationale).
The first area covered is **platform-independent path, file, and
configuration resolution**: `core/paths` and `core/config`.
It covers **platform-independent path, file, and configuration
resolution** (`core/paths`, `core/config`), the **standard commands**
every Yetano program offers (`core/manual`, `core/completion`,
`core/doctor`, `core/configcmd`, `core/version`; see
docs/program-conventions.md in the meta-repository), and secret
references in configuration (`core/secretref`).
```text
yetano.dev/yetano/core
@@ -16,6 +20,8 @@ yetano.dev/yetano/core/config
yetano.dev/yetano/core/manual
yetano.dev/yetano/core/completion
yetano.dev/yetano/core/doctor
yetano.dev/yetano/core/configcmd
yetano.dev/yetano/core/version
yetano.dev/yetano/core/secretref
```
@@ -150,7 +156,8 @@ machine-local override layer. Data/State/Cache/Log/Runtime live under
Unix, without an explicit override and without `XDG_RUNTIME_DIR` set, it
returns `paths.ErrRuntimeDirUnavailable` -- callers decide what to do.
Windows and macOS always resolve a runtime directory (no equivalent
"may legitimately not exist" case there); macOS Desktop resolves it from
"may legitimately not exist" case there; macOS CLI/Service system scope
uses `/var/run/<app>`, since macOS has no `/run`); macOS Desktop resolves it from
`$TMPDIR` (see ARCHITECTURE.md), the same OS-managed ephemeral directory
`NSTemporaryDirectory()` returns.
@@ -284,6 +291,46 @@ docs/program-conventions.md in the meta-repository):
`Run(args, stdout, stderr)` prints a table or `--json` and returns the
exit code (0 all good, 1 a check failed, 2 usage).
## core/configcmd: "<program> config"
`config create [--minimal|--full] [--force] [--output <file>]`,
`config validate`, `config upgrade [--write]` and `config path` for
every program, from one `configcmd.Spec`: the program's name and
`core.Application` (file name and directories), a minimal and a full
template, its `Validate(path)` function and, optionally, its config
struct as `Schema` (unknown-option detection, operator-named maps in
`upgrade`). `Spec.Optional` is for programs that also run without a
file, `Spec.None` for programs without configuration (the command then
says so). `Spec.Find` is the lookup a program should also use at
startup, so `config path` and the program always agree.
```go
spec := configcmd.Spec{
Name: "yasl", App: app,
Minimal: config.MinimalTemplate, Full: config.FullTemplate,
Validate: func(path string) error { _, err := config.Load(path); return err },
Schema: config.Config{},
}
os.Exit(configcmd.Run(spec, configFlag, args, os.Stdout, os.Stderr))
```
A program's tests call `configcmd.UndocumentedKeys(FullTemplate,
config.Config{})` and expect nothing, so every option stays documented
in the full template -- that is what keeps `config upgrade` useful.
`WarnUnknown` (log at startup) and `UnknownCheck` (a doctor check)
report options the program ignores. Taken over from
`yamase-core/pkg/configcmd`, which now wraps it.
## core/version: "<program> version [--json]"
The values stay in each program's `internal/version` (stamped with
`-ldflags -X`); `version.Info{Program, Version, Commit, BuildDate,
Contracts}.Run(args, stdout, stderr)` prints them as text or `--json`
(`program`, `version`, `commit`, `build_date`, `go`, `platform`,
`contracts` for Verse programs). Unstamped builds fall back to the VCS
revision Go embeds; a leading "v" is dropped. `Info.Short()` is the
one-line form for log lines and web UI footers.
## Security
- Environment expansion is variable substitution only -- never shell