chmod - implement quiet

This commit is contained in:
Nathan Fisher 2023-01-21 09:11:54 -05:00
parent 71a9f8839a
commit f68ae6df91

View File

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