Add new line primitive, bump version, allow bare filepaths

This commit is contained in:
Jonathan Turner
2019-12-03 19:44:59 +13:00
parent 3fa03eb7a4
commit efc879b955
37 changed files with 170 additions and 129 deletions

View File

@ -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(

View File

@ -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)
}

View File

@ -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();