Skip to content

refactor: Migrate CLI to Spectre.Console.Cli with modular architecture#63

Merged
liphvf merged 57 commits into
mainfrom
refact
Apr 19, 2026
Merged

refactor: Migrate CLI to Spectre.Console.Cli with modular architecture#63
liphvf merged 57 commits into
mainfrom
refact

Conversation

@liphvf
Copy link
Copy Markdown
Owner

@liphvf liphvf commented Apr 19, 2026

Summary

This PR delivers a comprehensive refactoring of the FurLab CLI architecture, migrating from a monolithic command structure to a modular, well-organized codebase.

Major Changes

1. CLI Framework Migration

  • Migrated from System.CommandLine to Spectre.Console.Cli
  • Implemented proper dependency injection via TypeRegistrar/TypeResolver
  • Added centralized exception handling

2. Command Structure

  • Each subcommand in its own folder: {Group}{Subcommand}Command.cs
  • Separated Settings and Config classes
  • New categories: Database, Claude, OpenCode, Winget, Files, Docker, Query, WindowsFeatures, Settings

3. Code Cleanup

  • Removed 50+ unused classes and services
  • Moved FurLabConstants to Constants folder
  • Consolidated exception handling

Files Changed

187 files, ~3,800 insertions, ~10,500 deletions

Test Coverage

All 140+ tests passing

liphvf added 30 commits April 14, 2026 21:47
Includes design, proposal, requirements, and implementation tasks for
automatic daily update checks, user notification, and update commands
- Deleted WingetOperationOptions and WingetOperationResult models as they are no longer needed.
- Removed WingetService which handled backup and restore operations for Winget packages.
- Deleted FileService which provided file operations including combining files.
- Updated DatabaseService to remove backup and restore methods, focusing on database listing and connection testing.
- Introduced DatabaseConnectionOptions model to encapsulate database connection parameters.
- Updated tests to remove dependencies on removed services.
…ogger and OperationResult classes; clean up SqlQueryAnalyzer and related tests
- Added .openspec.yaml and design.md for migration details
- Created proposal.md outlining the rationale and changes
- Defined new specs for command structure, DI bridge, exception handling, and core services
- Implemented tasks for core service preparation, CLI infrastructure setup, and command migration
- Removed static façade classes and ensured all commands utilize constructor injection
- Centralized exception handling with specific exit codes
- Organized command files to reflect the command hierarchy
…ection

- Updated DatabaseCommandTests to verify service resolution from DI.
- Refactored FileCommandTests to enhance file handling and encoding checks.
- Removed OpenCodeCommandTests due to redundancy.
- Simplified PgPassCommandTests to focus on utility functions.
- Enhanced QueryCommandTests for better command structure validation.
- Removed WingetCommandTests as they were no longer necessary.
- Updated task list in migration documentation to reflect completed tasks.
- Removed redundant `System.IO` namespace references in multiple files.
- Updated file access methods to use the `File` and `Directory` classes directly.
- Ensured consistent usage of file reading and writing methods across the codebase.
- Improved code readability by reducing verbosity in file operations.
- Implemented centralized exception handling in CommandApp using SetExceptionHandler.
- Mapped specific exceptions to exit codes for better error handling.
- Added visual exception formatting using Spectre.Console.
- Introduced IDockerService and IPostgresBinaryLocator interfaces for Docker and PostgreSQL binary management.
- Created IPostgresPasswordHandler for secure password input handling.
- Established update check mechanism for automatic version notifications via NuGet API.
- Enhanced user configuration structure to include update check state.
- Added commands for manual update checks and executions.
… SqlQueryAnalyzerTests, and UserConfigServiceTests to improve clarity and consistency. Update comments and assertions to reflect English language standards and enhance readability.
…operties from database commands and user configuration service
liphvf added 27 commits April 18, 2026 21:39
…ommand, DatabaseRestoreCommand, and OperationProgress models to simplify configuration
…ng from ProcessExecutor to simplify process execution
…s and introducing specific database exceptions
…rLab CLI

- Updated architecture overview to reflect changes in command parsing and dependency injection using Spectre.Console.Cli and Microsoft.Extensions.DependencyInjection.
- Enhanced command structure in documentation, detailing new command organization and responsibilities.
- Revised feature specifications to include new functionalities for database utilities, file management, and integration with Claude Code and OpenCode.
- Improved clarity on command usage, error handling, and business rules across various functionalities.
- Added new sections for managing database server configurations and enhanced security practices for credential handling.
- Implemented WindowsFeaturesExportSettings for export command settings.
- Created WindowsFeaturesImportCommand to import and enable Windows features from a JSON file.
- Added WindowsFeaturesImportSettings for import command settings.
- Developed WindowsFeaturesListCommand to list available Windows features.
- Introduced WindowsFeaturesListSettings to filter enabled features.
- Updated Program.cs to register new Windows features commands.
- Refactored process execution interfaces and models for better structure.
- Removed obsolete WingetBackupCommand and adjusted related commands.
- Added test support classes for improved unit testing.
@liphvf liphvf merged commit 20a372a into main Apr 19, 2026
1 check passed
@liphvf liphvf deleted the refact branch April 19, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant