1
0

Implement remove tool; Remove trash tool

This commit is contained in:
Jeff 2023-10-21 17:48:14 -04:00
parent 003a082074
commit 3355310d9d
2 changed files with 8 additions and 10 deletions

View File

@ -26,7 +26,6 @@ pub enum Tool {
Move(Vec<Expression>),
Read(Expression),
Remove(Expression),
Trash(Expression),
Write(Vec<Expression>),
// Format conversion
@ -132,12 +131,6 @@ impl AbstractTree for Tool {
Tool::Remove(expression)
}
"trash" => {
let expression_node = node.child(2).unwrap();
let expression = Expression::from_syntax_node(source, expression_node)?;
Tool::Trash(expression)
}
"write" => {
let expressions = parse_expressions(source, node)?;
@ -345,8 +338,14 @@ impl AbstractTree for Tool {
Ok(content)
}
Tool::Remove(_) => todo!(),
Tool::Trash(_) => todo!(),
Tool::Remove(expression) => {
let path_value = expression.run(source, context)?;
let path = PathBuf::from(path_value.as_string()?);
remove_file(path)?;
Ok(Value::Empty)
}
Tool::Write(_) => todo!(),
Tool::FromJson(_) => todo!(),
Tool::ToJson(_) => todo!(),

View File

@ -276,7 +276,6 @@ module.exports = grammar({
'move',
'read',
'remove',
'trash',
'write',
// Format conversion