Remove shape-directed import pattern parsing (#7570)

This commit is contained in:
Jakub Žádník
2022-12-22 16:36:13 +02:00
committed by GitHub
parent 74656bf976
commit 23a5c5dc09
12 changed files with 121 additions and 81 deletions

View File

@ -34,6 +34,13 @@ pub trait CallExt {
stack: &mut Stack,
pos: usize,
) -> Result<T, ShellError>;
fn req_parser_info<T: FromValue>(
&self,
engine_state: &EngineState,
stack: &mut Stack,
pos: usize,
) -> Result<T, ShellError>;
}
impl CallExt for Call {
@ -99,4 +106,23 @@ impl CallExt for Call {
))
}
}
fn req_parser_info<T: FromValue>(
&self,
engine_state: &EngineState,
stack: &mut Stack,
pos: usize,
) -> Result<T, ShellError> {
if let Some(expr) = self.parser_info_nth(pos) {
let result = eval_expression(engine_state, stack, expr)?;
FromValue::from_value(&result)
} else if self.parser_info.is_empty() {
Err(ShellError::AccessEmptyContent(self.head))
} else {
Err(ShellError::AccessBeyondEnd(
self.parser_info.len() - 1,
self.head,
))
}
}
}

View File

@ -814,6 +814,7 @@ pub fn eval_element_with_input(
],
redirect_stdout: false,
redirect_stderr: false,
parser_info: vec![],
},
input,
)