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

add --dry-run flag #152

Closed
edgimar opened this issue Oct 22, 2024 · 5 comments · Fixed by #156
Closed

add --dry-run flag #152

edgimar opened this issue Oct 22, 2024 · 5 comments · Fixed by #156

Comments

@edgimar
Copy link

edgimar commented Oct 22, 2024

For a tool that can make in-place modifications to many files, it is important to have a --dry-run flag. This allows one to see what would be changed without actually performing changes. If this output looks correct, then it can be run "for real".

@alexpovel
Copy link
Owner

Thanks for your report!

Makes sense, such a flag should exist. I'll look into providing it. It's similar in spirit to #149.

In the meantime, you can always not take any action (no replacement etc.), which will enter search mode and print in bold red what was found and would be modified if an action were taken. What's missing is of course showing what the final result looks like.

@edgimar
Copy link
Author

edgimar commented Oct 23, 2024

Another related nicety is something like the --backup flag as used in the rpl tool, which makes a backup copy of any changed files.

@alexpovel
Copy link
Owner

alexpovel commented Oct 23, 2024

Thanks for the pointer, hadn't heard of rpl before. I imagine srgn as a tool to search code primarily, and secondarily to manipulate code, and for that code to be under version control. So --backup isn't something I see as required. It looks easy enough to implement though, will take a look.

Let me know if those assumptions are wrong! Always interested in how srgn is used in the wild.

alexpovel added a commit that referenced this issue Oct 27, 2024
This change adds a new flag `--dry-run` that when
given, prevents otherwise destructive file
overwrite operations and instead prints a rich
diff. The diff contains names of files which would
be modified, and a git-like diff of what
modifications *would* be made.

The diff is human-readable, and not designed to be
easily machine-readable.

The change leverages the `similar` crate, on which
we transitively depended on already anyway.

Closes #152.
alexpovel added a commit that referenced this issue Oct 27, 2024
This change adds a new flag `--dry-run` that when
given, prevents otherwise destructive file
overwrite operations and instead prints a rich
diff. The diff contains names of files which would
be modified, and a git-like diff of what
modifications *would* be made.

The diff is human-readable, and not designed to be
easily machine-readable.

The change leverages the `similar` crate, on which
we transitively depended on already anyway.

Closes #152.
alexpovel added a commit that referenced this issue Oct 27, 2024
This change adds a new flag `--dry-run` that when
given, prevents otherwise destructive file
overwrite operations and instead prints a rich
diff. The diff contains names of files which would
be modified, and a git-like diff of what
modifications *would* be made.

The diff is human-readable, and not designed to be
easily machine-readable.

The change leverages the `similar` crate, on which
we transitively depended on already anyway.

Closes #152.
@alexpovel
Copy link
Owner

Hi @edgimar !

What do you think of the implementation in #156 ? The PR has a screenshot of how it could look like too.

alexpovel added a commit that referenced this issue Nov 3, 2024
This change adds a new flag `--dry-run` that when
given, prevents otherwise destructive file
overwrite operations and instead prints a rich
diff. The diff contains names of files which would
be modified, and a git-like diff of what
modifications *would* be made.

The diff is human-readable, and not designed to be
easily machine-readable.

The change leverages the `similar` crate, on which
we transitively depended on already anyway.

Closes #152.
alexpovel added a commit that referenced this issue Nov 3, 2024
This change adds a new flag `--dry-run` that when
given, prevents otherwise destructive file
overwrite operations and instead prints a rich
diff. The diff contains names of files which would
be modified, and a git-like (word) diff of what
modifications *would* be made.

The diff is human-readable, and not designed to be
easily machine-readable. It leverages the existing
search mode.

Closes #152.
@edgimar
Copy link
Author

edgimar commented Nov 11, 2024 via email

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 a pull request may close this issue.

2 participants