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 { // dry-run displays paths while walking, so don't print here.
// Concise because if in verbose mode, the path will be written in if !self.dry_run {
// the loop below.
self.config
.shell()
.concise(|shell| Ok(writeln!(shell.out(), "{}", path.display())?))?;
} else {
self.config self.config
.shell() .shell()
.verbose(|shell| shell.status("Removing", path.display()))?; .verbose(|shell| shell.status("Removing", path.display()))?;
@ -369,6 +364,10 @@ impl<'cfg> CleanContext<'cfg> {
let entry = entry?; let entry = entry?;
self.progress.on_clean()?; self.progress.on_clean()?;
if self.dry_run { 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 self.config
.shell() .shell()
.verbose(|shell| Ok(writeln!(shell.out(), "{}", entry.path().display())?))?; .verbose(|shell| Ok(writeln!(shell.out(), "{}", entry.path().display())?))?;

View File

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