forked from extern/nushell
Add general refactorings (#3996)
This commit is contained in:
@ -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");
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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, ¶ms, 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)],
|
||||
|
@ -80,7 +80,7 @@ fn exec(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
|
||||
Err(ShellError::labeled_error(
|
||||
"Error on exec",
|
||||
format!("{}", err),
|
||||
err.to_string(),
|
||||
&name,
|
||||
))
|
||||
}
|
||||
|
Reference in New Issue
Block a user