Skip to content

Conversation

@Akeoott
Copy link
Owner

@Akeoott Akeoott commented Jan 2, 2026

(forced everything back, redoing entire process)

Description

This PR implements a major architectural refactor of the cssync project, consolidating the CLI functionality into the backend, overhauling the configuration system, and introducing a more flexible and maintainable codebase. The changes remove the separate CLI project, streamline configuration handling with Newtonsoft.Json, and implement a robust command-line interface directly within the backend.

The refactor improves maintainability by reducing project complexity, enhances configuration flexibility with a dynamic JObject structure, and provides better cross-platform support through improved terminal detection and execution flow.

Changes

New Features

  • Integrated CLI: Removed the standalone cssync.Cli project and integrated CLI functionality directly into cssync.Backend
  • Dynamic Configuration System: Replaced rigid dictionary-based configuration with flexible JObject-based sections using Newtonsoft.Json
  • Argument Parsing: Implemented comprehensive command-line argument parsing in ParseInput.cs with categorized help system
  • Config Monitoring Loop: Added a config-aware execution loop in Cssync.cs that dynamically responds to configuration changes
  • Cross-platform Terminal Detection: Enhanced terminal detection with platform-specific implementations for Windows and Unix systems

Removed Features

  • Standalone CLI Project: Eliminated cssync.Cli project and all associated files
  • System.Text.Json Dependency: Removed in favor of Newtonsoft.Json for better JSON manipulation capabilities
  • Rigid Configuration Schema: Replaced fixed Variables and Timer dictionaries with flexible Sections JObject

Improvements

  • Configuration Flexibility: Refactored Json.cs to use Newtonsoft.Json with dynamic JObject sections instead of static dictionaries
  • Unified ModifyConfig: Streamlined ModifyConfig.cs to work with the new JObject-based configuration structure
  • Enhanced Help System: Created categorized help resources in Resources.cs with detailed configuration guidance
  • Simplified Project Structure: Updated cssync.sln to remove CLI project reference and cleaned up solution configuration
  • Better Error Handling: Improved error handling throughout configuration operations with more descriptive logging
  • Resource Documentation: Added comprehensive configuration documentation accessible via --help config command

Bug Fixes

  • Terminal Detection: Fixed cross-platform terminal detection to properly handle both Windows and Unix environments
  • Configuration File Monitoring: Implemented proper config file change detection using last write time tracking
  • Argument Parsing: Corrected argument count handling in MainBackend.Main() to prevent incorrect command execution
  • Build Artifact Management: Updated .gitignore to properly exclude build artifacts and added missing patterns

Other

  • Updated README: Refreshed README.md with new badge layout and updated project structure description
  • EditorConfig Enhancements: Extended .editorconfig to include JSON and JSONC files with consistent indentation rules
  • File Header Standardization: Updated copyright headers and license references across all modified files
  • Code Cleanup: Removed obsolete comments, consolidated duplicate logic, and improved code organization
  • Dependency Updates: Added Newtonsoft.Json package reference and removed unnecessary dependencies

Additional Information

Breaking Changes

  1. Configuration file format has changed from rigid dictionaries to flexible JObject structure
  2. CLI is now accessed directly through the backend executable instead of separate CLI project
  3. Configuration keys must now be accessed through the new Sections structure

Migration Notes

  • Existing configuration files will need to be regenerated using cssync --init
  • CLI users must now run the backend executable directly with command-line arguments
  • Configuration editing requires understanding the new JObject-based structure

Checklist

  • Code follows project standards
  • Documentation updated if required
  • Program compiles with no errors

- Remove CLI project file entirely as backend now handles command parsing
- Remove cssync.Cli from .sln following this change
- Implement `HasTerminal()` with cross-platform TTY checks
- Add args support for `--help`, `--enable`, `--disable`, and `--force`
- Introduce `ParseInput` helper for handling CLI arguments
- Validate terminal requirements before running backend
- Provide help text and improved usage feedback
- reorganized shields for GitHub last commit, stars, and repo size
- clarified project description removing rclone-specific mention
- added a Structure section explaining separation of backend and GUI
- updated table to reflect backend logic handling and planned GUI interface
- simplified note about backend independence and GUI plans
…c enable/disable

- refactored ModifyConfig to use a helper for section/key validation
- consolidated type-specific logic for editing, appending, and removing values
- updated AppendKey and RemoveKey to support both Variables and Timers sections
- added EnableDisableCssync and GetCssyncStatus methods to manage cssync Run state
- updated ParseInput to support --status flag and properly enable/disable cssync
- removed unused ForceArgument logic and simplified terminal check in Main
- replace inline help text in ParseInput with Resources static strings
- introduce Resources.cs to store help, config, rclone and cssync messages
- update ParseInput to use central help resources and add --init flag
- rename ModifyConfig.GetCssyncStatus() to GetStatus() for consistency
- improve unknown flag handling and compatibility error messaging
- extend .editorconfig to format json and jsonc files with 2-space indents
- remove legacy cssyncOptions string and unused command scaffolding
- change RunCssync signature to no-arg Task to align with upcoming flow
- add status check to prevent running when disabled in config
- update Program.cs to reference new Cssync.RunCssync usage (currently commented)
- leave TODO for future Cssync execution logic
…plify ModifyConfig

- Added Newtonsoft.Json dependency for flexible JSON handling
- Replaced System.Text.Json with Newtonsoft.Json for serialization/deserialization
- Refactored Config class to use a single JObject "Sections" instead of separate Variables/Timers dictionaries
- Updated Json helper to handle reading, writing, and generating config using JObject
- Updated ModifyConfig to work with JObject for all CRUD operations on config keys and arrays
- Simplified Enable/Disable cssync logic and value editing logic
- Improved logging for array manipulations and key existence checks
- Removed redundant try/catch blocks where validation handles errors
- Updated GetStatus/GetConfigStatus and other methods to align with new JObject structure
- Refined HelpConfig text for clarity and conciseness
  - Simplified explanations of "Run", "Variables", and "Timers"
  - Updated examples and formatting for easier reading
  - Included guidance for rclone setup with links
- Added 'builds' folder to .gitignore to ignore local build artifacts
… config

- Cssync.RunCssync now monitors config and stops automatically if "Run" is false
- Introduced CancellationToken and background task loop (CssyncLoop)
- Added Json.Serialize helper for future use
@Akeoott Akeoott self-assigned this Jan 2, 2026
@Akeoott Akeoott merged commit df98ba9 into dev Jan 2, 2026
3 checks passed
@Akeoott Akeoott changed the title Major refactor: CLI consolidation + config overhaul (forced everything back, redoing entire process) (Entire redo) Major refactor: CLI consolidation + config overhaul Jan 2, 2026
@Akeoott Akeoott deleted the refactor/program-usage branch January 2, 2026 01:06
@Akeoott Akeoott mentioned this pull request Jan 2, 2026
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.

2 participants