Finish fixing failing tests.

This commit is contained in:
Jonathan Turner
2019-09-08 13:35:02 +12:00
parent 4cdaed1ad4
commit 84628f298d
3 changed files with 37 additions and 7 deletions

View File

@ -58,7 +58,7 @@ pub fn autoview(
}
}
};
} else if is_single_text_value(&input) {
} else if is_single_origined_text_value(&input) {
let text = context.get_command("textview");
if let Some(text) = text {
let result = text.run(raw.with_input(input), &context.commands);
@ -73,6 +73,15 @@ pub fn autoview(
}
}
}
} else if is_single_text_value(&input) {
for i in input {
match i.item {
Value::Primitive(Primitive::String(s)) => {
println!("{}", s);
}
_ => {}
}
}
} else {
let table = context.expect_command("table");
let result = table.run(raw.with_input(input), &context.commands);
@ -96,3 +105,20 @@ fn is_single_text_value(input: &Vec<Tagged<Value>>) -> bool {
false
}
}
fn is_single_origined_text_value(input: &Vec<Tagged<Value>>) -> bool {
if input.len() != 1 {
return false;
}
if let Tagged {
item: Value::Primitive(Primitive::String(_)),
tag: Tag {
origin: Some(_), ..
},
} = input[0]
{
true
} else {
false
}
}