Refactor AnyGen CLI for better state management#187
Open
manucian-official wants to merge 1 commit intoHKUDS:mainfrom
Open
Refactor AnyGen CLI for better state management#187manucian-official wants to merge 1 commit intoHKUDS:mainfrom
manucian-official wants to merge 1 commit intoHKUDS:mainfrom
Conversation
Refactor AnyGen CLI to use centralized AppContext for global state management and improve output handling.
Collaborator
|
@manucian-official Same problem as #180. The AppContext dataclass is a fine idea (~10 lines), but the rest of the PR deletes 15 of ~20 commands with no replacement. That's not refactoring. Keep all existing commands, fix the 4 bugs from #180 review, and submit only the state management change:
Do not delete commands. Do not remove CLI options from |
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.
Refactor: CLI Architecture Optimization
Overview
This update delivers a focused internal refactor of the AnyGen CLI, improving structure, consistency, and maintainability without introducing any breaking changes.
Highlights
Centralized State Management
Introduced
AppContextas a single source of truth, replacing fragmented global variables.Unified Output Layer
Standardized all outputs via a single handler, ensuring consistency across CLI and JSON modes.
Normalized Error Handling
Implemented a decorator-based approach for clean, predictable error reporting.
Lazy Initialization
Deferred session loading to reduce unnecessary I/O and improve startup performance.
Reduced Duplication
Abstracted repeated patterns, resulting in a leaner and more maintainable codebase.
Simplified CLI Structure
Streamlined command definitions for improved readability and usability.
Design Principles
Compatibility
Summary
This refactor strengthens the internal architecture, delivering a cleaner, more scalable foundation for future development while remaining completely transparent to end users.