1
0

Implement workdir tool

This commit is contained in:
Jeff 2023-10-22 16:41:37 -04:00
parent b327068e17
commit bd83ccd301
5 changed files with 1241 additions and 1194 deletions

View File

@ -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()?;

View File

@ -267,6 +267,7 @@ module.exports = grammar({
'output',
'output_error',
'type',
'workdir',
// Filesystem
'append',

View File

@ -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"
}
]
}

View File

@ -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