improve code

This commit is contained in:
Loïc Riegel 2025-03-30 18:01:07 +02:00
parent 28ed857102
commit b8ebb562ca

View File

@ -283,34 +283,28 @@ fn action(input: &Value, args: &Arguments, head: Span) -> Value {
internal_span, internal_span,
} = input } = input
{ {
match timezone { if let Some(tz) = timezone {
None => (), return Value::error(
Some(tz) => { ShellError::IncompatibleParameters {
return Value::error( left_message: "got a record as input".into(),
ShellError::IncompatibleParameters { left_span: head,
left_message: "got a record as input".into(), right_message: "the timezone should be included in the record".into(),
left_span: head, right_span: tz.span,
right_message: "the timezone should be included in the record".into(), },
right_span: tz.span, head,
}, );
head,
);
}
} }
match dateformat { if let Some(dt) = dateformat {
None => (), return Value::error(
Some(dt) => { ShellError::IncompatibleParameters {
return Value::error( left_message: "got a record as input".into(),
ShellError::IncompatibleParameters { left_span: head,
left_message: "got a record as input".into(), right_message: "cannot be used with records".into(),
left_span: head, right_span: dt.span,
right_message: "cannot be used with records".into(), },
right_span: dt.span, head,
}, );
head,
);
}
} }
return merge_record(record, head, *internal_span); return merge_record(record, head, *internal_span);