Commit Graph

482 Commits

Author SHA1 Message Date
Jeremiah Russell
992414e0b9 ♻️ refactor(rule_processor): extract process_label and add internal ops trait for unit testing 2025-10-19 09:51:56 +01:00
Jeremiah Russell
d91b3e3b92 ♻️ refactor(rule_processor): add TRASH_LABEL, correct Gmail scopes, early returns, and improve idioms 2025-10-19 09:51:56 +01:00
Jeremiah Russell
ea948eda27 📝 docs(rule_processor): add module and method docs with safety notes and doctest examples 2025-10-19 09:51:56 +01:00
Jerus Bot
099a074a61 chore: update prlog for pr 2025-10-19 08:52:23 +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
724c930234 docs(eol_rule): add comprehensive documentation and examples 2025-10-19 08:52:23 +01:00
Jerus Bot
329fa677c9 chore: update prlog for pr 2025-10-19 07:54:12 +01:00
Jeremiah Russell
8fbe12346f 🐛 fix(retention): fix debug string formatting in retention struct
- change format macro to resolve cargo clippy warning
2025-10-19 07:54:12 +01:00
Jeremiah Russell
051507856a feat(retention): enhance message age with parsing and validation
- add `TryFrom<&str>` implementation for `MessageAge`
  - allows creating `MessageAge` from string slices
  - returns `Error` for invalid formats
- improve `MessageAge::new` to return a `Result`
  - changes error type to `Error` enum
- add `Error::InvalidMessageAge` for specific message age errors
- mark `MessageAge::parse` and other methods as `must_use`
- use byte string literals for character matching in `parse`
- update error messages to include the invalid input value
- add `#[derive(Hash)]` to `MessageAge`
2025-10-19 07:54:12 +01:00
Jeremiah Russell
5c2124ead4 🐛 fix(cli): correct error mapping in add_cli
- fix error mapping for message age creation
- use direct error propagation instead of config error mapping
2025-10-19 07:54:12 +01:00
Jeremiah Russell
1448c791d9 feat(retention): implement retention policy configuration
- define struct for retention policy with message age and label generation
- add methods to create, access, and modify retention policies
- implement default values, cloning, equality, and debug formatting
2025-10-19 07:54:12 +01:00
Jeremiah Russell
32db9cb51a feat(error): add invalid message age error
- add `InvalidMessageAge` error variant to the `Error` enum
- include a message parameter to provide details about the invalid age
2025-10-19 07:54:12 +01:00
Jeremiah Russell
c40e4dfa86 feat(retention): introduce message age specification
- introduces `MessageAge` enum to represent retention periods
- supports days, weeks, months, and years
- adds parsing and formatting for `MessageAge` instances
- includes label generation for categorization
2025-10-19 07:54:12 +01:00
Jeremiah Russell
dd16da8740 🐛 fix(rules): handle message age creation error
- handle the error when creating MessageAge and return a ConfigError::Message
2025-10-19 07:54:12 +01:00
Jeremiah Russell
722d57086e feat(retention): enhance retention policy configuration
- introduce `Retention` struct for managing message retention policies
- add `new` constructor with age and generate_label options
- implement getter methods for age and generate_label
- add `set_generate_label` to control label generation dynamically
- provide examples and usage documentation
- include comprehensive unit tests

📝 docs(retention): document retention policy configuration

- provide detailed documentation for `Retention` struct
- include usage examples for creating and configuring retention policies
- explain the purpose of the `age` and `generate_label` fields
- describe the behavior of `set_generate_label` method
2025-10-19 07:54:12 +01:00
Jerus Bot
821e28e6ff chore: update prlog for pr 2025-10-18 08:11:30 +01:00
Jeremiah Russell
bb0f85a9c7 📝 docs(lib): update rules save and load examples
- uncomment rules save and load examples
2025-10-18 08:11:30 +01:00
Jeremiah Russell
258a0517aa 📝 docs(lib): comment out save and load rules examples
- comment out save and load rules examples
- these examples are not working and should be fixed later
2025-10-18 08:11:30 +01:00
Jeremiah Russell
4d96a65628 📝 docs(lib): enhance documentation with examples and clarifications
- update code examples for better clarity and correctness
- include example of setting up client with OAuth credentials
- add example of client configuration with file paths
- fix minor formatting issues and broken links
2025-10-18 08:11:30 +01:00
Jeremiah Russell
75dc301fe3 📝 docs(lib): update lib.md path
- fix the path of lib.md to be under docs/lib
2025-10-18 08:11:30 +01:00
Jeremiah Russell
eac99bddbc 📝 docs(lib): rename lib.md and update code block formatting
- Renamed `docs/readme/lib.md` to `docs/lib/lib.md` for better file structure.
- Updated code blocks to remove `path=null start=null` for cleaner rendering.
2025-10-18 08:11:30 +01:00
Jeremiah Russell
40cfa2a223 📝 docs(lib): add detailed documentation for library features
- add gmail query syntax guide
- provide performance and limits information
- explain logging functionality
- describe security considerations
- include troubleshooting section
- add "see also" links
2025-10-18 08:11:30 +01:00
Jeremiah Russell
5dd0608994 🐛 fix(build): correct readme generation script
- fix readme generation script to point to the correct file
2025-10-18 08:11:30 +01:00
Jeremiah Russell
4c296cce5d 📝 docs(readme): update readme content
- fix readme generation script to include lib docs
2025-10-18 08:11:30 +01:00
Jeremiah Russell
7afbb1d56d 📝 docs(lib): add comprehensive library documentation
- introduce library's purpose, installation, and quick start guide
- describe core types (gmailclient, clientconfig, rules) with usage examples
- explain configuration options (oauth2, config file, environment variables)
- detail error handling, async runtime requirements, and gmail query syntax
- cover performance considerations (pagination, rate limits, batch operations)
- provide logging setup, security considerations, and troubleshooting tips
- include links to cli documentation, examples, api reference, and repository
2025-10-18 08:11:30 +01:00
Jeremiah Russell
4aa47173c4 📝 docs(lib): remove gmail query syntax and troubleshooting
- remove gmail query syntax
- remove performance & limits
- remove logging
- remove security considerations
- remove troubleshooting
- remove see also
2025-10-18 08:11:30 +01:00
Jeremiah Russell
a5ea370af2 📝 docs(readme): improve library and CLI documentation
- enhance documentation for library and CLI tools, providing comprehensive guides
- include installation, quick start, core types, config, error handling, async runtime
- add gmail query syntax, performance details, logging, security, and troubleshooting
- provide detailed command references, examples, workflows, safety features, and debugging
- update readme headers to reflect new doc structure
2025-10-18 08:11:30 +01:00
Jerus Bot
2cace859ca chore: Release cull-gmail v0.0.10 2025-10-16 16:39:19 +00:00
Jerus Bot
0891795e41 chore: update prlog for pr 2025-10-16 17:28:55 +01:00
Jeremiah Russell
754e5229ae ♻️ refactor(cli): extract action execution into a function
- move action execution logic into `execute_action` function
- improve code readability and reduce duplication
2025-10-16 17:28:55 +01:00
Jeremiah Russell
9116e7c406 ♻️ refactor(cli): rename get_config to get_rules
- rename function to better reflect its purpose
2025-10-16 17:28:55 +01:00
Jeremiah Russell
f1e873009b ♻️ refactor(cli): extract rule execution to separate function
- move rule execution logic to run_rules function
- this improves code organization and testability
2025-10-16 17:28:55 +01:00
Jeremiah Russell
0136d7da09 feat(cli): add default subcommand for rule execution
- Add a default subcommand that executes rules based on configuration.
- Load rules and configuration to determine execution behavior.
- Implement dry run functionality to prevent unintended actions.
2025-10-16 17:28:55 +01:00
Jerus Bot
93a53086be chore: update prlog for pr 2025-10-16 15:37:01 +01:00
Jeremiah Russell
486bcb1934 ♻️ refactor(config): improve ConfigRoot to handle different root types
- change ConfigRoot to use RootBase enum for different root types (Crate, Home, Root, None)
- add full_path method to resolve the full path based on RootBase and path
- update tests to use full_path to string conversion for assertions
2025-10-16 15:37:01 +01:00
Jeremiah Russell
73e9eed539 🐛 fix(gmail): fix token persistence path
- Use the persist_path from the config instead of a hardcoded path to ensure tokens are persisted to the correct location
2025-10-16 15:37:01 +01:00
Jeremiah Russell
368e78b1cc feat(config): implement config builder pattern for ClientConfig
- introduce ConfigBuilder struct for constructing ClientConfig instances
- add methods to ConfigBuilder for setting various configuration parameters
- implement a build method to create the ClientConfig instance
- add a default implementation for ConfigBuilder
- enhance ClientConfig with persist_path for token persistence
- update ClientConfig::new_from_configuration to use config_root.full_path()
- add ClientConfig::persist_path() to report the full path to the file to persist tokens
2025-10-16 15:37:01 +01:00
Jerus Bot
a6d5186cd9 chore: update prlog for pr 2025-10-16 11:21:40 +01:00
Jeremiah Russell
556d7bd598 ♻️ refactor(utils): improve config directory creation
- simplify directory creation logic
- handle existing directory case more efficiently
2025-10-16 11:21:40 +01:00
Jeremiah Russell
3111a1feff chore(build): bump rust version to 1.88
- update rust version in:
  - .circleci/config.yml
  - Cargo.toml
  - README.md
  - docs/readme/head.md
2025-10-16 11:21:40 +01:00
Jeremiah Russell
44b98d0657 feat(cli): load configurations from toml file
- load configurations from `cull-gmail.toml`
- set default value for rules in config
2025-10-16 11:21:40 +01:00
Jeremiah Russell
1ae34efb93 🐛 fix(config): resolve credential file path issue
- fix the problem of reading credential file in the production environment
- use config_root to find credential file
2025-10-16 11:21:40 +01:00
Jeremiah Russell
b17e72e6f3 feat(client_config): add config root parsing with regex
- introduce regex-based parsing for config root strings
- support 'h', 'r', and 'c' prefixes for home, root, and crate paths
- add tests for parsing different config root types
2025-10-16 11:21:40 +01:00
Jeremiah Russell
8ab89cdb0a feat(utils): add test utils module
- add test_utils module to provide common utilities for tests
- add get_test_logger function for initializing test logger
2025-10-16 11:21:40 +01:00
Jeremiah Russell
959e61743e feat(deps): add lazy-regex crate
- this commit introduces the lazy-regex crate to improve regex performance
- lazy-regex allows for the definition of static regexes that are compiled at compile time
2025-10-16 11:21:40 +01:00
Jeremiah Russell
0e68aa5560 feat(dependencies): add lazy-regex dependency
- add lazy-regex to improve regex performance
2025-10-16 11:21:40 +01:00