mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Command tests (#922)
* WIP command tests * Finish marking todo tests * update * update * Windows cd test ignoring
This commit is contained in:
@ -94,6 +94,13 @@ END:VCALENDAR' | from ics",
|
||||
|
||||
fn from_ics(input: PipelineData, head: Span, config: &Config) -> Result<PipelineData, ShellError> {
|
||||
let input_string = input.collect_string("", config)?;
|
||||
|
||||
let input_string = input_string
|
||||
.lines()
|
||||
.map(|x| x.trim().to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
|
||||
let input_bytes = input_string.as_bytes();
|
||||
let buf_reader = BufReader::new(input_bytes);
|
||||
let parser = ical::IcalParser::new(buf_reader);
|
||||
@ -103,9 +110,9 @@ fn from_ics(input: PipelineData, head: Span, config: &Config) -> Result<Pipeline
|
||||
for calendar in parser {
|
||||
match calendar {
|
||||
Ok(c) => output.push(calendar_to_value(c, head)),
|
||||
Err(_) => output.push(Value::Error {
|
||||
Err(e) => output.push(Value::Error {
|
||||
error: ShellError::UnsupportedInput(
|
||||
"input cannot be parsed as .ics".to_string(),
|
||||
format!("input cannot be parsed as .ics ({})", e),
|
||||
head,
|
||||
),
|
||||
}),
|
||||
|
@ -125,14 +125,24 @@ END:VCARD' | from vcf",
|
||||
|
||||
fn from_vcf(input: PipelineData, head: Span, config: &Config) -> Result<PipelineData, ShellError> {
|
||||
let input_string = input.collect_string("", config)?;
|
||||
|
||||
let input_string = input_string
|
||||
.lines()
|
||||
.map(|x| x.trim().to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
|
||||
let input_bytes = input_string.as_bytes();
|
||||
let cursor = std::io::Cursor::new(input_bytes);
|
||||
let parser = ical::VcardParser::new(cursor);
|
||||
|
||||
let iter = parser.map(move |contact| match contact {
|
||||
Ok(c) => contact_to_value(c, head),
|
||||
Err(_) => Value::Error {
|
||||
error: ShellError::UnsupportedInput("input cannot be parsed as .vcf".to_string(), head),
|
||||
Err(e) => Value::Error {
|
||||
error: ShellError::UnsupportedInput(
|
||||
format!("input cannot be parsed as .vcf ({})", e),
|
||||
head,
|
||||
),
|
||||
},
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user