refactor(cli): standardize command implementation and reduce boilerplate#80
Merged
refactor(cli): standardize command implementation and reduce boilerplate#80
Conversation
Centralize DI container lifecycle management and unify command output logic to improve maintainability and consistency across the CLI. - Implement `ExecuteWithContainer` to manage configuration loading, container initialization, and graceful shutdown centrally. - Introduce `Formatter` interface and `WriteOutput` helper to standardize JSON and Text output, removing repetitive conditional blocks. - Move interactive CLI prompts and policy validation to a new `internal/ui` package. - Consolidate shared parsing logic for algorithms and format types into `helpers.go`. - Standardize I/O handling across all commands using the `IOTuple` abstraction. - Add `SERVER_SHUTDOWN_TIMEOUT` configuration to decouple server exit from DB settings. - Implement strict validation for `ACTIVE_MASTER_KEY_ID` during rotation. - Add comprehensive docstrings and unit tests for CLI definitions and helpers. - Resolve `gosec` linting issues and fix build failures in command tests.
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.
Centralize DI container lifecycle management and unify command output logic to improve maintainability and consistency across the CLI.
ExecuteWithContainerto manage configuration loading, container initialization, and graceful shutdown centrally.Formatterinterface andWriteOutputhelper to standardize JSON and Text output, removing repetitive conditional blocks.internal/uipackage.helpers.go.IOTupleabstraction.SERVER_SHUTDOWN_TIMEOUTconfiguration to decouple server exit from DB settings.ACTIVE_MASTER_KEY_IDduring rotation.goseclinting issues and fix build failures in command tests.