feat: add --dry-run mode to Go implementation
Add comprehensive dry-run functionality that allows users to test their configuration without making any changes to CouchDB. The feature includes: - New --dry-run/-n command line flag with help and completion support - Skips all CouchDB write operations while preserving IMAP operations - Provides detailed logging of what would be done in normal mode - Shows sample message data and metadata updates that would occur - Maintains all existing functionality when dry-run is disabled This addresses the critical usability need identified in ANALYSIS.md for safe configuration testing before making database changes. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
14d2aafbf0
commit
61ba952155
2 changed files with 100 additions and 57 deletions
|
|
@ -86,6 +86,7 @@ func (ms *MailSource) IsArchiveMode() bool {
|
|||
type CommandLineArgs struct {
|
||||
ConfigPath string
|
||||
MaxMessages int
|
||||
DryRun bool
|
||||
}
|
||||
|
||||
// ParseCommandLine parses command line arguments using GNU-style options
|
||||
|
|
@ -95,6 +96,7 @@ func ParseCommandLine() *CommandLineArgs {
|
|||
// Define long options with -- and short options with -
|
||||
pflag.StringVarP(&args.ConfigPath, "config", "c", "", "Path to configuration file")
|
||||
pflag.IntVarP(&args.MaxMessages, "max-messages", "m", 0, "Maximum number of messages to process per mailbox per run (0 = no limit)")
|
||||
pflag.BoolVarP(&args.DryRun, "dry-run", "n", false, "Show what would be done without making any changes")
|
||||
|
||||
// Add utility options
|
||||
pflag.BoolP("help", "h", false, "Show help message")
|
||||
|
|
@ -146,7 +148,7 @@ _%s_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
|
||||
|
|
@ -217,5 +219,8 @@ func LoadConfigWithDiscovery(args *CommandLineArgs) (*Config, error) {
|
|||
} else {
|
||||
fmt.Printf("Maximum messages per mailbox: unlimited\n")
|
||||
}
|
||||
if args.DryRun {
|
||||
fmt.Printf("DRY-RUN MODE: No changes will be made to CouchDB\n")
|
||||
}
|
||||
return LoadConfig(configPath)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue