feat: add --dry-run mode to Rust implementation

Add comprehensive dry-run functionality to the Rust implementation that allows
users to test their configuration without making any changes to CouchDB:

- Added --dry-run/-n command line flag with clap argument parsing
- Extended CommandLineArgs struct with dry_run field
- Updated bash completion script to include new flag
- Comprehensive dry-run logic throughout sync coordinator:
  - Skip database creation with informative logging
  - Skip sync metadata retrieval and use config fallback
  - Skip deleted message handling in sync mode
  - Skip message and attachment storage with detailed simulation
  - Skip sync metadata updates with summary information
- Enhanced summary output to clearly indicate dry-run vs normal mode
- Updated all tests to include new dry_run field
- Maintains all IMAP operations for realistic mail discovery testing

This brings the Rust implementation to feature parity with the Go version
for safe configuration testing as identified in ANALYSIS.md.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ole-Morten Duesund 2025-08-03 18:26:01 +02:00
commit 322fb094a5
4 changed files with 153 additions and 76 deletions

View file

@ -28,6 +28,11 @@ pub fn parse_command_line() -> CommandLineArgs {
.help("Maximum number of messages to process per mailbox per run (0 = no limit)")
.value_parser(clap::value_parser!(u32))
.action(ArgAction::Set))
.arg(Arg::new("dry-run")
.short('n')
.long("dry-run")
.help("Show what would be done without making any changes")
.action(ArgAction::SetTrue))
.arg(Arg::new("generate-bash-completion")
.long("generate-bash-completion")
.help("Generate bash completion script and exit")
@ -44,6 +49,7 @@ pub fn parse_command_line() -> CommandLineArgs {
CommandLineArgs {
config_path: matches.get_one::<String>("config").map(|s| s.clone()),
max_messages: matches.get_one::<u32>("max-messages").copied(),
dry_run: matches.get_flag("dry-run"),
generate_bash_completion: matches.get_flag("generate-bash-completion"),
help: false, // Using clap's built-in help
}
@ -83,7 +89,7 @@ _{}_completions() {{
if [[ $cur == -* ]]; then
# Complete with available options
local opts="-c --config -m --max-messages -h --help --generate-bash-completion"
local opts="-c --config -m --max-messages -n --dry-run -h --help --generate-bash-completion"
COMPREPLY=($(compgen -W "$opts" -- "$cur"))
return
fi