Implement remove tool; Remove trash tool
This commit is contained in:
parent
003a082074
commit
3355310d9d
@ -26,7 +26,6 @@ pub enum Tool {
|
|||||||
Move(Vec<Expression>),
|
Move(Vec<Expression>),
|
||||||
Read(Expression),
|
Read(Expression),
|
||||||
Remove(Expression),
|
Remove(Expression),
|
||||||
Trash(Expression),
|
|
||||||
Write(Vec<Expression>),
|
Write(Vec<Expression>),
|
||||||
|
|
||||||
// Format conversion
|
// Format conversion
|
||||||
@ -132,12 +131,6 @@ impl AbstractTree for Tool {
|
|||||||
|
|
||||||
Tool::Remove(expression)
|
Tool::Remove(expression)
|
||||||
}
|
}
|
||||||
"trash" => {
|
|
||||||
let expression_node = node.child(2).unwrap();
|
|
||||||
let expression = Expression::from_syntax_node(source, expression_node)?;
|
|
||||||
|
|
||||||
Tool::Trash(expression)
|
|
||||||
}
|
|
||||||
"write" => {
|
"write" => {
|
||||||
let expressions = parse_expressions(source, node)?;
|
let expressions = parse_expressions(source, node)?;
|
||||||
|
|
||||||
@ -345,8 +338,14 @@ impl AbstractTree for Tool {
|
|||||||
|
|
||||||
Ok(content)
|
Ok(content)
|
||||||
}
|
}
|
||||||
Tool::Remove(_) => todo!(),
|
Tool::Remove(expression) => {
|
||||||
Tool::Trash(_) => todo!(),
|
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::Write(_) => todo!(),
|
||||||
Tool::FromJson(_) => todo!(),
|
Tool::FromJson(_) => todo!(),
|
||||||
Tool::ToJson(_) => todo!(),
|
Tool::ToJson(_) => todo!(),
|
||||||
|
@ -276,7 +276,6 @@ module.exports = grammar({
|
|||||||
'move',
|
'move',
|
||||||
'read',
|
'read',
|
||||||
'remove',
|
'remove',
|
||||||
'trash',
|
|
||||||
'write',
|
'write',
|
||||||
|
|
||||||
// Format conversion
|
// Format conversion
|
||||||
|
Loading…
Reference in New Issue
Block a user