chmod - implement `quiet`

This commit is contained in:
Nathan Fisher 2023-01-21 09:11:54 -05:00
parent 71a9f8839a
commit f68ae6df91
1 changed files with 10 additions and 5 deletions

View File

@ -72,13 +72,20 @@ impl Cmd for Chmod {
let action = Action {
path,
feedback,
quiet: matches.get_flag("quiet"),
mode,
};
action.apply()?;
if let Err(e) = action.apply() {
if !matches.get_flag("quiet") {
return Err(e.into());
}
}
if matches.get_flag("recursive") {
if action.path.is_dir() {
action.recurse()?;
if let Err(e) = action.recurse() {
if !matches.get_flag("quiet") {
return Err(e.into());
}
}
}
}
}
@ -94,7 +101,6 @@ impl Cmd for Chmod {
struct Action<'a> {
path: PathBuf,
feedback: Option<Feedback>,
quiet: bool,
mode: &'a str,
}
@ -151,7 +157,6 @@ impl Action<'_> {
Self {
path: entry.path().to_path_buf(),
feedback: self.feedback,
quiet: self.quiet,
mode: self.mode,
}
}