Implement workdir tool
This commit is contained in:
parent
b327068e17
commit
bd83ccd301
@ -1,4 +1,5 @@
|
||||
use std::{
|
||||
env::current_dir,
|
||||
fs::{copy, metadata, read_dir, read_to_string, remove_file, write, File},
|
||||
io::Write,
|
||||
path::PathBuf,
|
||||
@ -21,6 +22,7 @@ pub enum Tool {
|
||||
Output(Vec<Expression>),
|
||||
OutputError(Vec<Expression>),
|
||||
Type(Expression),
|
||||
Workdir,
|
||||
|
||||
// Filesystem
|
||||
Append(Vec<Expression>),
|
||||
@ -117,6 +119,7 @@ impl AbstractTree for Tool {
|
||||
|
||||
Tool::Type(expression)
|
||||
}
|
||||
"workdir" => Tool::Workdir,
|
||||
"append" => {
|
||||
let expressions = parse_expressions(source, node)?;
|
||||
|
||||
@ -314,6 +317,11 @@ impl AbstractTree for Tool {
|
||||
|
||||
Ok(Value::String(value_type.to_string()))
|
||||
}
|
||||
Tool::Workdir => {
|
||||
let workdir = current_dir()?.to_string_lossy().to_string();
|
||||
|
||||
Ok(Value::String(workdir))
|
||||
}
|
||||
Tool::Append(expressions) => {
|
||||
let path_value = expressions[0].run(source, context)?;
|
||||
let path = path_value.as_string()?;
|
||||
|
@ -267,6 +267,7 @@ module.exports = grammar({
|
||||
'output',
|
||||
'output_error',
|
||||
'type',
|
||||
'workdir',
|
||||
|
||||
// Filesystem
|
||||
'append',
|
||||
|
@ -1094,6 +1094,10 @@
|
||||
"type": "STRING",
|
||||
"value": "type"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "workdir"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "append"
|
||||
@ -1168,11 +1172,11 @@
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "rows"
|
||||
"value": "columns"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "columns"
|
||||
"value": "rows"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -897,6 +897,10 @@
|
||||
"type": "while",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "workdir",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "write",
|
||||
"named": false
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user