Commit Graph

11 Commits

Author SHA1 Message Date
Jeremiah Russell
dc41101dcb ♻️ refactor(rules): execute rules by action
- executes rules by action: `Trash` first, then `Delete`
- a label may have a `trash` and `delete` rule applied
2025-10-30 12:26:12 +00:00
Jeremiah Russell
cb53faf3b3 feat(rules): support multiple actions per label
- support trash and delete actions for the same label
- add `run_rules_for_action` function to filter rules by action
- update `get_rules_by_label` to `get_rules_by_label_for_action`
- update `find_label` to return a vector of rule ids
- update `remove_rule_by_label` to remove all rules with the label
2025-10-30 12:26:12 +00:00
Jeremiah Russell
d4cc2621db Add configurable rules directory support
- Add rules configuration option to ClientConfig
- Support custom rules file paths via config and CLI
- Add --rules-dir option to init command
- Update Rules struct to accept custom file paths
- Add helper functions for rules path resolution
- Fix doc comment formatting issues
- Add integration tests for custom rules paths
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
2b420e53cb style: format code with rustfmt 2025-10-19 08:52:23 +01:00
Jeremiah Russell
8f908df8f3 refactor(rules): apply idiomatic patterns and resolve clippy warnings
- Change add_rule parameter from Option<&String> to Option<&str> for better ergonomics
- Use iterator methods (flat_map, any) instead of manual loops and collections
- Collapse nested if conditions using let-else patterns
- Use format string interpolation instead of separate arguments
- Avoid unnecessary String allocations in label comparisons
- Update CLI code to use as_deref() for Option<String> to Option<&str> conversion
- Update all documentation examples and tests to match new API
- All functionality preserved; API is more idiomatic and efficient
2025-10-19 08:52:23 +01:00
Jeremiah Russell
a43eb9e4a2 refactor(rules): replace unwrap() with explicit error handling and propagate errors safely
- Replace Option::unwrap() with pattern matching in add_rule label check
- Handle home directory resolution failures with proper Error types
- Add directory creation in save() to ensure parent directories exist
- Replace chrono unwraps with ? operator for date calculations
- Use unwrap_or with sensible defaults for parsing edge cases
- Keep unwrap in test code where immediate failure is desired
- All existing functionality preserved; no API changes
2025-10-19 08:52:23 +01:00
Jeremiah Russell
74512bdea3 test(rules): add unit tests covering all public methods and edge cases
- Add comprehensive test coverage for all Rules public methods
- Test both success and error paths with proper assertions
- Add PartialEq derive to EolAction to enable comparisons in tests
- Include edge cases like duplicate labels and nonexistent IDs
- Mark file system integration tests as ignore to avoid interference
2025-10-19 08:52:23 +01:00
Jeremiah Russell
222bd87415 docs(rules): add comprehensive documentation and usage examples for Rules and its methods 2025-10-19 08:52:23 +01:00
Jeremiah Russell
2fa7cd21ab ♻️ refactor(rules): remove credentials config
- remove unused credentials configuration
- remove credentials file setting/getting logic
- rename config file to rules.toml
2025-10-15 14:30:07 +01:00
Jeremiah Russell
0bc71f5b75 ♻️ refactor: rename Config to Rules
- rename Config struct to Rules to better reflect its purpose
- update all references to Config to Rules
2025-10-15 12:39:20 +01:00