cleanup + clippy suggestions

This commit is contained in:
xiuxiu62 2021-10-09 21:17:08 -07:00
parent 97ca242634
commit beb15dcc77

View file

@ -1,11 +1,9 @@
use std::collections::HashMap;
use std::env::current_dir; use std::env::current_dir;
use std::os::unix::prelude::FileTypeExt; use std::os::unix::prelude::FileTypeExt;
use std::path::{Path, PathBuf}; use std::path::PathBuf;
use glob::Paths;
use nu_engine::CallExt; use nu_engine::CallExt;
use nu_protocol::ast::{Call, Expression}; use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EvaluationContext}; use nu_protocol::engine::{Command, EvaluationContext};
use nu_protocol::{ShellError, Signature, SyntaxShape, Value, ValueStream}; use nu_protocol::{ShellError, Signature, SyntaxShape, Value, ValueStream};
@ -144,7 +142,7 @@ fn rm(context: &EvaluationContext, call: &Call) -> Result<Value, ShellError> {
} }
fn rm_helper(call: &Call, args: RmArgs) -> Vec<Value> { fn rm_helper(call: &Call, args: RmArgs) -> Vec<Value> {
let (targets, recursive, trash, permanent, force) = ( let (targets, recursive, trash, _permanent, force) = (
args.targets, args.targets,
args.recursive, args.recursive,
args.trash, args.trash,
@ -219,33 +217,33 @@ fn rm_helper(call: &Call, args: RmArgs) -> Vec<Value> {
} }
if let Err(e) = result { if let Err(e) = result {
return Value::Error { Value::Error {
error: ShellError::RemoveNotPossible( error: ShellError::RemoveNotPossible(
format!("Could not delete because: {:}\nTry '--trash' flag", e), format!("Could not delete because: {:}\nTry '--trash' flag", e),
call.head, call.head,
), ),
};
} else {
return Value::String {
val: format!("deleted {:}", f.to_string_lossy()).into(),
span: call.positional[i].span,
};
} }
} else { } else {
return Value::Error { Value::String {
val: format!("deleted {:}", f.to_string_lossy()),
span: call.positional[i].span,
}
}
} else {
Value::Error {
error: ShellError::RemoveNotPossible( error: ShellError::RemoveNotPossible(
"Cannot remove. try --recursive".to_string(), "Cannot remove. try --recursive".to_string(),
call.positional[i].span, call.positional[i].span,
), ),
}; }
} }
} else { } else {
return Value::Error { Value::Error {
error: ShellError::RemoveNotPossible( error: ShellError::RemoveNotPossible(
"no such file or directory".to_string(), "no such file or directory".to_string(),
call.positional[i].span, call.positional[i].span,
), ),
}; }
} }
}) })
.collect() .collect()