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

Added option to undo last renaming operation #64

Merged
merged 3 commits into from
Mar 13, 2023
Merged

Added option to undo last renaming operation #64

merged 3 commits into from
Mar 13, 2023

Conversation

frsche
Copy link
Contributor

@frsche frsche commented Jan 16, 2023

Hi,
I have added the command line option "--undo" to undo the last renaming operation.

Do you think this might be a useful feature? If this works reliably we could also think about giving the "--yes" flag by default (and adding an "--interative" flag).

Copy link
Collaborator

@mtimkovich mtimkovich left a comment

Choose a reason for hiding this comment

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

This is great! Sorry for taking so long to getting to review this. I just have some minor comments.

src/main.rs Outdated
Comment on lines 356 to 366
// make paths absolute to that undo does not depend on CWD
let original = if r.original.is_relative() {
std::env::current_dir()?.join(r.original)
} else {
r.original
};
let new = if r.new.is_relative() {
std::env::current_dir()?.join(r.new)
} else {
r.new
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

could you make a function for converting the relative path to an absolute one so we don't repeat here?

if opts.undo {
let replacements = load_undo_renames(backup_file)?;
execute_renames(&replacements, opts.rename_command)?;
return Ok(());
Copy link
Collaborator

Choose a reason for hiding this comment

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

optional: Do you want to add some output here for when the undo completes successfully?

@mtimkovich mtimkovich merged commit cc36e11 into marcusbuffett:master Mar 13, 2023
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