Commit Graph

12 Commits

Author SHA1 Message Date
Jeremiah Russell
c39e64f0ac Implement core logic for --skip-rules in init 2025-10-23 11:16:25 +01:00
Jeremiah Russell
0b24767065 Add --skip-rules flag to init command 2025-10-23 11:16:25 +01:00
Jeremiah Russell
2b29382d5e 🎨 Apply cargo fmt formatting 2025-10-22 06:38:00 +01:00
Jeremiah Russell
10a1a1e058 🐛 Fix duplicate CreateDir operation in init planning
Prevent duplicate CreateDir operations when rules directory
is the same as config directory by checking if the directory
creation has already been planned before adding another one.
2025-10-22 06:38:00 +01:00
Jeremiah Russell
bcb93fd68f feat: integrate configurable rules path throughout CLI
- Make parse_config_root() public for reuse in main.rs
- Add get_rules_path() helper to extract and resolve rules path from config
- Update main CLI to use configured rules path for default rule execution
- Add run_with_rules_path() method to RulesCli for custom path support
- Update all unit tests to include rules_dir field
- Rules path now supports h:, c:, r: prefixes throughout the application
2025-10-22 06:38:00 +01:00
Jeremiah Russell
2083c5c5fe feat: add configurable rules directory support to Rules and InitCli
- Add Rules::load_from() and Rules::save_to() methods for custom paths
- Add --rules-dir option to init command
- Support h:, c:, r: path prefixes for rules directory
- Generate config file with correct rules path when using separate directory
- Create rules directory automatically if it doesn't exist
- Maintain backward compatibility with default ~/.cull-gmail/rules.toml
2025-10-22 06:38:00 +01:00
Jeremiah Russell
df9d2b6c8a 🔧 fix: address clippy warnings after refactoring
- Change &PathBuf to &Path parameter in plan_credential_file_operation
- Use inline format string in log message
- Both formatting and linting now clean
2025-10-21 14:48:31 +01:00
Jeremiah Russell
aaa4ebcbde ♻️ refactor: reduce cognitive complexity of plan_operations and execute_operation
## Refactoring Changes

### plan_operations function:
- Split monolithic function into focused single-purpose methods
- Extract plan_config_directory, plan_credential_file_operation, etc.
- Add check_file_conflicts helper to eliminate repetitive error checking
- Fix should_backup logic (was always returning true)

### execute_operation function:
- Replace large match statement with focused execution methods
- Extract execute_create_directory, execute_copy_file, etc.
- Add handle_existing_file helper for backup/interactive logic
- Add prompt_for_overwrite and apply_permissions_if_needed helpers

## Benefits:
- Each function now has single responsibility
- Eliminated code duplication in conflict checking and interactive prompts
- Reduced cyclomatic complexity from ~15 to 2-3 per function
- Improved testability and maintainability
- All tests continue to pass
2025-10-21 14:48:31 +01:00
Jeremiah Russell
8f79081b4f 🔧 fix: address clippy warnings and improve code formatting 2025-10-21 14:48:31 +01:00
Jeremiah Russell
2cfd16c8ac 🧪 test(init): unit tests for planning and file IO 2025-10-21 14:48:31 +01:00
Jeremiah Russell
0a047dd547 🏗️ feat(init): implement plan and apply operations
- Add comprehensive Operation enum for file/directory operations
- Implement path resolution with h:, c:, r: prefix support
- Create default config and rules file templates
- Add interactive prompts for credential file setup
- Support dry-run mode with detailed operation preview
- Include progress bar for operation execution
- Implement secure file permissions (0600 for credentials, 0700 for tokens)
- Add timestamped backup functionality for existing files
- Support force overwrite and interactive conflict resolution
2025-10-21 14:48:31 +01:00
Jeremiah Russell
fd70ef9511 feat(cli): scaffold InitCli subcommand and clap wiring 2025-10-21 14:48:31 +01:00