Don't display paths with cargo clean --dry-run without --verbose

The paths themselves aren't particularly interesting.
This commit is contained in:
Eric Huss 2023-09-10 12:57:00 -07:00
parent f61d42d5ef
commit c2047345bd
2 changed files with 6 additions and 8 deletions

View File

@ -334,13 +334,8 @@ impl<'cfg> CleanContext<'cfg> {
}
};
if self.dry_run {
// Concise because if in verbose mode, the path will be written in
// the loop below.
self.config
.shell()
.concise(|shell| Ok(writeln!(shell.out(), "{}", path.display())?))?;
} else {
// dry-run displays paths while walking, so don't print here.
if !self.dry_run {
self.config
.shell()
.verbose(|shell| shell.status("Removing", path.display()))?;
@ -369,6 +364,10 @@ impl<'cfg> CleanContext<'cfg> {
let entry = entry?;
self.progress.on_clean()?;
if self.dry_run {
// This prints the path without the "Removing" status since I feel
// like it can be surprising or even frightening if cargo says it
// is removing something without actually removing it. And I can't
// come up with a different verb to use as the status.
self.config
.shell()
.verbose(|shell| Ok(writeln!(shell.out(), "{}", entry.path().display())?))?;

View File

@ -825,7 +825,6 @@ fn clean_dry_run() {
p.cargo("check").run();
let before = ls_r();
p.cargo("clean --dry-run")
.with_stdout("[CWD]/target")
.with_stderr(
"[SUMMARY] [..] files, [..] total\n\
[WARNING] no files deleted due to --dry-run",