2026-10-07 14:56:13 +00:00
|
|
|
# Simple consumer
|
|
|
|
|
|
2026-11-04 03:52:46 +00:00
|
|
|
This example imports `go.maximumdirect.net/ckconfig` and
|
2026-11-04 16:17:49 +00:00
|
|
|
`go.maximumdirect.net/commandkit`; use ckconfig v0.3.0 with core
|
2026-11-04 15:05:42 +00:00
|
|
|
v0.3.0, ConfigKit v1.1.0, and Go 1.27.0. Set `GOWORK=off GOTOOLCHAIN=local`
|
|
|
|
|
for the commands below.
|
2026-11-04 03:52:46 +00:00
|
|
|
|
2026-10-07 14:56:13 +00:00
|
|
|
Run the maintained example with:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
go run . config show
|
2026-10-26 03:44:19 +00:00
|
|
|
go run . config show --config fixtures/before.yml --verbose
|
|
|
|
|
go run . config show --config fixtures/before.yml --quiet
|
2026-11-07 04:54:44 +00:00
|
|
|
go run . config explain --list --under /schema
|
|
|
|
|
go run . config show --path /greeting --set '/greeting="Hi"'
|
2026-10-11 21:52:47 +00:00
|
|
|
go run . config diff --config fixtures/before.yml --against-config fixtures/after.yml
|
2026-11-07 04:54:44 +00:00
|
|
|
go run . config diff --set '/greeting="Hi"' --details --check
|
|
|
|
|
go run . config validate --config fixtures/invalid.yml --details --severity error
|
|
|
|
|
go run . config sources --config fixtures/invalid.yml --source-id source-1
|
2026-10-07 14:56:13 +00:00
|
|
|
go run . greet
|
|
|
|
|
go run . greet --count=0 --tag=first --tag second
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The `config` family comes from one typed ConfigKit scope. The custom `greet`
|
|
|
|
|
command uses CommandKit's typed bindings and shows the difference between an
|
|
|
|
|
omitted `--count` and an explicitly supplied zero, plus ordered repeated tags.
|
2026-10-11 21:52:47 +00:00
|
|
|
With no `--config`, application settings use the in-memory default. A supplied
|
|
|
|
|
configuration and overlay are passed to ConfigKit unchanged. The comparison
|
|
|
|
|
command loads the two local fixtures and reports `changes.greeting: Goodbye`.
|
2026-10-26 03:44:19 +00:00
|
|
|
The before fixture uses schema version 1, which ConfigKit reports as a provider
|
|
|
|
|
warning in verbose mode. Ordinary mode hides the warning while preserving the
|
|
|
|
|
effective YAML report; quiet mode suppresses that report.
|
2026-11-07 04:54:44 +00:00
|
|
|
The invalid fixture demonstrates a failed-load report and captured source
|
|
|
|
|
inventory; `source-1` is the ID from that fixture's acquisition. The scope opts
|
|
|
|
|
in to transient overrides and passes them into its normal ConfigKit load. The
|
|
|
|
|
diff example compares an overridden left side with ordinary configuration on
|
|
|
|
|
the right and returns status 3 because the values differ.
|