mirror of
https://github.com/nushell/nushell
synced 2025-01-15 14:44:14 +00:00
run rustfmt on match plugin
This commit is contained in:
parent
be51aad9ad
commit
36f2b09cad
1 changed files with 19 additions and 12 deletions
|
@ -1,6 +1,6 @@
|
||||||
use nu::{
|
use nu::{
|
||||||
serve_plugin, CallInfo, Plugin, Primitive, ReturnSuccess, ReturnValue, ShellError,
|
serve_plugin, CallInfo, Plugin, Primitive, ReturnSuccess, ReturnValue, ShellError, Signature,
|
||||||
Signature, SyntaxShape, Tagged, Value,
|
SyntaxShape, Tagged, Value,
|
||||||
};
|
};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ struct Match {
|
||||||
|
|
||||||
impl Match {
|
impl Match {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Match {
|
Match {
|
||||||
column: String::new(),
|
column: String::new(),
|
||||||
regex: Regex::new("").unwrap(),
|
regex: Regex::new("").unwrap(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,9 @@ impl Plugin for Match {
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
return Err(ShellError::string(format!(
|
return Err(ShellError::string(format!(
|
||||||
"Unrecognized type in params: {:?}", args[0])));
|
"Unrecognized type in params: {:?}",
|
||||||
|
args[0]
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
match &args[1] {
|
match &args[1] {
|
||||||
|
@ -48,8 +50,10 @@ impl Plugin for Match {
|
||||||
self.regex = Regex::new(s).unwrap();
|
self.regex = Regex::new(s).unwrap();
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
return Err(ShellError::string(format!(
|
return Err(ShellError::string(format!(
|
||||||
"Unrecognized type in params: {:?}", args[0])));
|
"Unrecognized type in params: {:?}",
|
||||||
|
args[0]
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,21 +77,24 @@ impl Plugin for Match {
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
return Err(ShellError::string(format!(
|
return Err(ShellError::string(format!(
|
||||||
"value is not a string! {:?}", &val)));
|
"value is not a string! {:?}",
|
||||||
|
&val
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Err(ShellError::string(format!(
|
return Err(ShellError::string(format!(
|
||||||
"column not in row! {:?} {:?}", &self.column, dict)));
|
"column not in row! {:?} {:?}",
|
||||||
|
&self.column, dict
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
return Err(ShellError::string(format!(
|
return Err(ShellError::string(format!("Not a row! {:?}", &input)));
|
||||||
"Not a row! {:?}", &input)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if flag {
|
if flag {
|
||||||
Ok(vec![Ok(ReturnSuccess::Value(input))])
|
Ok(vec![Ok(ReturnSuccess::Value(input))])
|
||||||
} else {
|
} else {
|
||||||
Ok(vec![])
|
Ok(vec![])
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue