Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Multiple backup directories #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

nbw
Copy link
Collaborator

@nbw nbw commented Sep 24, 2023

Support multiple backup directories

example:

cargo -- run --work-dir=/temp --backup-dir=/temp-backup,/temp-backup2,/temp-backup3 --source-dir=temp-backup

The reason a --source-dir flag is required is we need to know the original source of truth. If we used --backup-dir with multiple directories (like the above example) then we'd have to choose from the list of backup-dir


// The directory that holds the original source files
#[arg(short, long)]
source_dir: PathBuf,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are your thoughts on making this optional, and using the first backup_dir if it isn't provided?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed. I tried that initially. If that's possible then yes I agree. I can't do source_dir = backup_dir.clone() or whatever I tried so I wasn't sure how to get around that one. I'll give it a shot and if it doesn't work then I'd like for you to show me how to do it.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd do something like making source_dir: Option<PathBuf>, and then doing something later in the code like let source_dir = source_dir.unwrap_or(backup_dir.first().unwrap())

@@ -27,18 +27,23 @@ struct Args {
#[arg(short, long)]
work_dir: PathBuf,

/// The directory that will be copied to. Used to initialize source dir
/// The directory that will be copied to
#[arg(short, long)]
backup_dir: PathBuf,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not rename this to bakcup_dirs, and make it a Vec?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants