Add general refactorings (#3996)

This commit is contained in:
Marcin Puc
2021-09-10 00:44:22 +02:00
committed by GitHub
parent ae9f4135c0
commit 51c74eebd0
165 changed files with 540 additions and 615 deletions

View File

@ -22,12 +22,12 @@ impl WholeStreamCommand for Clear {
fn run(&self, _: CommandArgs) -> Result<InputStream, ShellError> {
if cfg!(windows) {
Command::new("cmd")
.args(&["/C", "cls"])
.args(["/C", "cls"])
.status()
.expect("failed to execute process");
} else if cfg!(unix) {
Command::new("/bin/sh")
.args(&["-c", "clear"])
.args(["-c", "clear"])
.status()
.expect("failed to execute process");
}

View File

@ -51,7 +51,7 @@ pub fn clip(args: CommandArgs) -> Result<ActionStream, ShellError> {
if !values.is_empty() {
let mut first = true;
for i in values.iter() {
for i in &values {
if !first {
new_copy_data.push('\n');
} else {

View File

@ -99,7 +99,7 @@ fn du(args: CommandArgs) -> Result<ActionStream, ShellError> {
let exclude = args.exclude.map_or(Ok(None), move |x| {
Pattern::new(&x.item)
.map(Option::Some)
.map(Some)
.map_err(|e| ShellError::labeled_error(e.msg, "glob error", x.tag.clone()))
})?;
@ -148,11 +148,10 @@ fn du(args: CommandArgs) -> Result<ActionStream, ShellError> {
output.push(Ok(ReturnSuccess::Value(
DirInfo::new(p, &params, max_depth, ctrl_c.clone()).into(),
)));
} else {
for v in FileInfo::new(p, deref, tag.clone()).into_iter() {
output.push(Ok(ReturnSuccess::Value(v.into())));
}
} else if let Ok(v) = FileInfo::new(p, deref, tag.clone()) {
output.push(Ok(ReturnSuccess::Value(v.into())));
}
output
}
Err(e) => vec![Err(e)],

View File

@ -80,7 +80,7 @@ fn exec(args: CommandArgs) -> Result<OutputStream, ShellError> {
Err(ShellError::labeled_error(
"Error on exec",
format!("{}", err),
err.to_string(),
&name,
))
}