Repository navigation
feat: add NewConfigCommand, and document the config-key vocabulary - #24
Merged
Merged
Conversation
NewConfigCommand returns a config command with validate, example and schema subcommands for a service's config type. validate checks a file without starting the service and reports every unknown key, with its full path, and every setting Validate rejects, together. example and schema are generated from the config struct's mapstructure keys and desc tags, or supplied by the service when it generates richer ones at build time. doc/config-keys.md records the key vocabulary Dioad services share, taken from connect's convention, and how keys, flags and environment variables relate. examples/config-command is a runnable service using the command. The optional key-alias mechanism in the issue is not included. Fixes #19 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SS4MAwAn85D1gkEzLtjYaZ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cli.NewConfigCommand(kind, newConfig, opts...)returns aconfigcommand withvalidate,exampleandschemasubcommands.validatechecks a file without starting the service and reports every unknown key (with its full path) and every settingValidaterejects, together.exampleandschemaare generated from the config struct'smapstructurekeys anddesctags;WithConfigExampleandWithConfigSchemalet a service supply richer ones generated at build time.doc/config-keys.mdrecords the key vocabulary Dioad services share, and how keys, flags and environment variables relate.examples/config-commandis a runnable service using the command (its run command prints and exits; its tests run each subcommand).ExampleNewConfigCommandrunsvalidateagainst an in-memory config.Not included: the optional key-alias mechanism. The reflection-based example and schema can't read doc comments; the struct walk the issue mentions lifting into
dioad/configdoes not exist there yet.Fixes #19
Stacked on the service-logger PR (this base branch).
🤖 Generated with Claude Code
https://claude.ai/code/session_01SS4MAwAn85D1gkEzLtjYaZ