Replace hardcoded flag strings with constants in viper calls #103
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.
This PR addresses issue #XXX by replacing hardcoded flag strings with constants throughout all viper.Get* calls to prevent flags from getting out of sync.
Problem
Previously, flag definitions and viper usage relied on hardcoded strings that could easily get out of sync if flag names were changed:
Solution
Introduced flag constants in each command file to ensure consistency:
Changes Made
cmd/root.go
): Added constants for all server flags (host, port, brokers, topic, db, tls-cert, tls-key, config, json-logging, debug)cli/cmd/root.go
): Added constants for common flags and removed duplicateviper.AutomaticEnv()
callBenefits
Testing
The implementation keeps flag constants localized to their respective command files as requested, avoiding cross-project dependencies while ensuring consistency between flag definitions and viper usage.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.