mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 08:09:23 +02:00
Add new line primitive, bump version, allow bare filepaths
This commit is contained in:
@ -72,16 +72,14 @@ impl Plugin for Match {
|
||||
tag,
|
||||
} => {
|
||||
if let Some(val) = dict.entries.get(&self.column) {
|
||||
match val {
|
||||
Value {
|
||||
value: UntaggedValue::Primitive(Primitive::String(s)),
|
||||
..
|
||||
} => {
|
||||
flag = self.regex.is_match(s);
|
||||
}
|
||||
Value { tag, .. } => {
|
||||
return Err(ShellError::labeled_error("expected string", "value", tag));
|
||||
}
|
||||
if let Ok(s) = val.as_string() {
|
||||
flag = self.regex.is_match(&s);
|
||||
} else {
|
||||
return Err(ShellError::labeled_error(
|
||||
"expected string",
|
||||
"value",
|
||||
val.tag(),
|
||||
));
|
||||
}
|
||||
} else {
|
||||
return Err(ShellError::labeled_error(
|
||||
|
@ -129,24 +129,16 @@ impl Plugin for Parse {
|
||||
|
||||
fn filter(&mut self, input: Value) -> Result<Vec<ReturnValue>, ShellError> {
|
||||
let mut results = vec![];
|
||||
match &input {
|
||||
Value {
|
||||
tag,
|
||||
value: UntaggedValue::Primitive(Primitive::String(s)),
|
||||
} => {
|
||||
//self.full_input.push_str(&s);
|
||||
if let Ok(s) = input.as_string() {
|
||||
for cap in self.regex.captures_iter(&s) {
|
||||
let mut dict = TaggedDictBuilder::new(input.tag());
|
||||
|
||||
for cap in self.regex.captures_iter(&s) {
|
||||
let mut dict = TaggedDictBuilder::new(tag);
|
||||
|
||||
for (idx, column_name) in self.column_names.iter().enumerate() {
|
||||
dict.insert_untagged(column_name, value::string(&cap[idx + 1].to_string()));
|
||||
}
|
||||
|
||||
results.push(ReturnSuccess::value(dict.into_value()));
|
||||
for (idx, column_name) in self.column_names.iter().enumerate() {
|
||||
dict.insert_untagged(column_name, value::string(&cap[idx + 1].to_string()));
|
||||
}
|
||||
|
||||
results.push(ReturnSuccess::value(dict.into_value()));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
Ok(results)
|
||||
}
|
||||
|
@ -155,6 +155,9 @@ impl Str {
|
||||
UntaggedValue::Primitive(Primitive::String(ref s)) => {
|
||||
Ok(self.apply(&s)?.into_value(value.tag()))
|
||||
}
|
||||
UntaggedValue::Primitive(Primitive::Line(ref s)) => {
|
||||
Ok(self.apply(&s)?.into_value(value.tag()))
|
||||
}
|
||||
UntaggedValue::Row(_) => match self.field {
|
||||
Some(ref f) => {
|
||||
let fields = f.clone();
|
||||
|
Reference in New Issue
Block a user