Repository navigation
fix: name flags after config keys and bind them to the keys; describe the logging flags - #22
Merged
Merged
Conversation
sflags names a flag from the Go field path, but the config is decoded from the fields' mapstructure keys. For a renamed field, a named struct squashed into its parent, or a nested block the two differ, so the flag showed in --help while its value went to a viper key nothing decodes. Each flag is now named from its field's mapstructure key path, so the flag for log.level is --log-level, and InitConfig binds it to that key. A flag tag name on a field still wins. A flag whose name changed stays accepted under its old name as a hidden, deprecated alias. Environment overrides now follow the config key too. Fixes #18 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SS4MAwAn85D1gkEzLtjYaZ
…onfig keys Every logging.Config field gets a description, taken from its doc comment, so --help no longer shows eight bare flags. Mode, reserved for future use, is hidden. The flags are now --log-level, --log-use-local-time and so on, matching the log.* config keys; the --logging-* names stay accepted as hidden, deprecated aliases (see the previous commit). UndocumentedFlags walks a command tree and returns the visible flags with no usage text, so a consumer can fail its own tests if one appears. Fixes #16 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
#18. sflags names a flag from the Go field path, but the config is decoded from the
mapstructurekeys. For a renamed field, a named,squashstruct, or a nested block the two differ, so the flag showed in--helpwhile its value went to a viper key nothing decodes.mapstructurekey path (--log-levelforlog.level), andInitConfigbinds it to that key.flag:"name"tag on a field, or an ancestor, still chooses the name.#16. Every
logging.Configfield gets adesc,modeis hidden, and the flags become--log-*(so--log-use-local-time), with the--logging-*names kept as deprecated aliases.cli.UndocumentedFlags(cmd)returns the visible flags with no usage, so a consumer can guard its CLI in a test.Compatibility
Flag names change (old names still work, hidden and deprecated), environment variables now follow the config key, and generated CLI reference docs will differ.
Fixes #18
Fixes #16
Stacked: #20 and #19 PRs build on this branch.
🤖 Generated with Claude Code
https://claude.ai/code/session_01SS4MAwAn85D1gkEzLtjYaZ