configcmd.OneOf for alternative fields; completion.Files for paths

UndocumentedKeys reported the unused alternatives of a struct like
SecretRef (env/file/value) as undocumented; a struct implementing the
marker configcmd.OneOf now counts as documented with one alternative,
and upgrade offers none of the others to a file that chose one.

completion.Tree gets the key completion.Files: that level completes
file and directory paths besides command names (bash, zsh, fish,
PowerShell), for programs started as "<program> [path]" like yamc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
terminarandClaude Opus 5.5 committed 2026-10-31 23:40:45 +01:00
1 parent 83f4228e66
commit 131d82642c
6 files changed
+244 -13

No files matched your search

+8 -1
View File
@@ -321,7 +321,10 @@ docs/program-conventions.md in the meta-repository):
- `completion.Run(program, tree, args, w)` prints a bash, zsh, fish or
PowerShell completion script generated from a static `completion.Tree`
of the program's commands.
of the program's commands. A level that also takes a path (a program
without subcommands, started as `<program> [path]`) adds the key
`completion.Files`; the script then completes files and directories
there besides the command names.
- `doctor.Report` collects the locations the program resolves
(`AddPaths(app)` adds the standard `core/paths` ones) and named checks;
`Run(args, stdout, stderr)` prints a table or `--json` and returns the
@@ -353,6 +356,10 @@ 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.
A struct whose fields are alternatives (a secret from `env`, `file` or
`value`) implements the marker `configcmd.OneOf` (`func (SecretRef)
ConfigOneOf() {}`): one alternative in the template documents it, and
`upgrade` offers none of the others to a file that already chose one.
`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.