diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3fa2601..13fd3b2 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
### v0.1.2
+* New **mv** command #8
* New **rm** command #15
* New **rmdir** command #14
* New **assert_eq** command #22
diff --git a/docs/sdk.md b/docs/sdk.md
index e358599..49bfa82 100644
--- a/docs/sdk.md
+++ b/docs/sdk.md
@@ -22,6 +22,7 @@
* [sdk::fs::GetCanonicalPath](#sdk__fs__GetCanonicalPath)
* [sdk::fs::GetFileName](#sdk__fs__GetFileName)
* [sdk::fs::GetParentDirectory](#sdk__fs__GetParentDirectory)
+* [sdk::fs::MovePath](#sdk__fs__MovePath)
* [sdk::fs::Print](#sdk__fs__Print)
* [sdk::fs::Read](#sdk__fs__Read)
* [sdk::fs::Write](#sdk__fs__Write)
@@ -52,9 +53,8 @@ None
#### Examples
-This example creates a new **my_echo** alias that will print the prefix before the requested arguments.
-
```sh
+# This example creates a new **my_echo** alias that will print the prefix before the requested arguments.
alias my_echo echo [ECHO]
# This will print "[ECHO] hello world "
@@ -115,15 +115,11 @@ The amount of arguments printed.
#### Examples
-Print multiple arguments:
-
```sh
+# Print multiple arguments:
echo hello world
-```
-Print multiple spaces between words
-
-```sh
+# Print multiple spaces between words
echo "hello world"
```
@@ -187,9 +183,8 @@ None
#### Examples
-Simple example iteration over the list of letters:
-
```sh
+# Simple example iteration over the list of letters:
args = array a b c
for arg in args
@@ -197,11 +192,8 @@ for arg in args
end_for
release args
-```
-Example nested loops:
-
-```sh
+# Example nested loops:
range = array 1 2 3
for i in range
for j in range
@@ -255,27 +247,20 @@ The function invocation returns the output provided by the return command.
#### Examples
-Simple example of a function definition which echo 'hello world' and exists.
-
```sh
+# Simple example of a function definition which echo 'hello world' and exists.
+
# function start
function hello_world
-
-echo hello world
-
+ echo hello world
end_function
# function invocation
hello_world
-```
-Example of calling a function and returning a value
-
-```sh
+# Example of calling a function and returning a value
function get_hello_world
-
-return "hello world"
-
+ return "hello world"
end_function
# function invocation
@@ -283,32 +268,24 @@ text = get_hello_world
# this will print "hello world"
echo ${text}
-```
-Example of passing arguments
-
-```sh
+# Example of passing arguments
function print_input
-
-# $1 is set with the value 'hello'
-# $2 is set with the value 'world'
-echo ${1} ${2}
-
+ # $1 is set with the value 'hello'
+ # $2 is set with the value 'world'
+ echo ${1} ${2}
end_function
print_input hello world
-```
-Functions can call other functions
-
-```sh
+# Functions can call other functions
function get_one
-return 1
+ return 1
end_function
function get_number
-number = get_one
-return ${number}
+ number = get_one
+ return ${number}
end_function
output = get_number
@@ -400,43 +377,30 @@ None
#### Examples
-Simple example of an if statement that evaluates the argument value as true and echos "in if"
-
```sh
+# Simple example of an if statement that evaluates the argument value as true and echos "in if"
if true
echo in if
end_if
-```
-Example of using **not** command to reverse the output value
-
-```sh
+# Example of using **not** command to reverse the output value
if not false
echo in if
end_if
-```
-Example of an if statement that evaluates the command as true and echos "in if"
-
-```sh
+# Example of an if statement that evaluates the command as true and echos "in if"
if set true
echo in if
end_if
-```
-Example of if condition returning a falsy result and navigation goes to the else block which echos "in else"
-
-```sh
+# Example of if condition returning a falsy result and navigation goes to the else block which echos "in else"
if set false
echo should not be here
else
echo in else
end_if
-```
-Example of if condition returning a falsy result and navigation goes to the elseif block has a truthy condition
-
-```sh
+# Example of if condition returning a falsy result and navigation goes to the elseif block has a truthy condition
if set false
echo should not be here
elseif set true
@@ -444,11 +408,8 @@ elseif set true
else
echo should not be here
end_if
-```
-Nested if example:
-
-```sh
+# Nested if example:
if set false
echo should not be here
elseif set true
@@ -498,19 +459,15 @@ The switched value of the input.
#### Examples
-Simple example of converting true/false values
-
```sh
+# Simple example of converting true/false values
is_false = not true
echo is false: ${is_false}
is_true = not false
echo is true: ${is_true}
-```
-Example of converting command output value
-
-```sh
+# Example of converting command output value
is_false = not set true
echo is false: ${is_false}
@@ -570,15 +527,11 @@ The first command argument.
#### Examples
-Return a simple text value:
-
```sh
+# Return simple 'hello' text value
var = set hello
-```
-Return an expanded value:
-
-```sh
+# Return expanded value: 'home: ....'
var = set "home: ${HOME}"
```
@@ -665,15 +618,11 @@ The current directory path.
#### Examples
-Print the current directory:
-
```sh
+# Print the current directory:
pwd
-```
-Print and also store the current directory:
-
-```sh
+# Print and also store the current directory:
directory = pwd
```
@@ -730,15 +679,11 @@ The new current directory.
#### Examples
-Move to user home directory and store the path in the home variable
-
```sh
+# Move to user home directory and store the path in the home variable
home = cd
-```
-Move to the requested directory
-
-```sh
+# Move to the requested directory
cd ./scripts
```
@@ -940,6 +885,45 @@ directory = dirname ./dir/file.txt
#### Aliases:
dirname
+
+## sdk::fs::MovePath
+```sh
+var = mv source target
+```
+
+This command moves the requested source path to the target path.
+
+* If the source and target paths define a file, it will move the file as defined.
+* If target path is a directory path, it will move the source file/directory into that target directory path.
+
+All missing parent directories in the target path will be created as needed.
+
+#### Parameters
+
+* The source path to copy
+* The target path
+
+#### Return Value
+
+**true** if the move was successful.
+
+#### Examples
+
+```sh
+# move a single file
+moved = mv ./file1.txt ./file2.txt
+
+# move a single file into the target directory
+moved = mv ./file1.txt ./somedir
+
+# move entire directory into another directory
+moved = mv ./source ./target/subdir
+```
+
+
+#### Aliases:
+mv
+
## sdk::fs::Print
```sh
@@ -1051,15 +1035,11 @@ Optionally a base name to access the process stout, stderr and exit code informa
#### Examples
-Example of running a command and flushing its output to the parent process.
-
```sh
+# Example of running a command and flushing its output to the parent process.
exec echo hello world
-```
-Example of running a command and storing its output.
-
-```sh
+# Example of running a command and storing its output.
output = exec echo hello world
stdout = set ${output.stdout}
@@ -1093,15 +1073,11 @@ The exit code.
#### Examples
-Example of exit with code '0'
-
```sh
+# exit with code '0'
code = exit
-```
-Example of exit with error code '1'
-
-```sh
+# exit with code '1'
code = exit 1
```
@@ -1137,20 +1113,16 @@ It is considered falsy and will exist with an error.
#### Examples
-Valid condition:
-
```sh
+# valid conditions
assert ok
assert true
assert yes
value = set "some text"
assert ${value}
-```
-Error example:
-
-```sh
+# error conditions
assert
assert false
assert 0
@@ -1181,19 +1153,15 @@ If they are not, the command will exist with an error.
#### Examples
-Valid condition:
-
```sh
+# valid conditions
assert_eq yes yes
assert_eq false false
value = set "some text"
assert_eq ${value} "some text"
-```
-Error example:
-
-```sh
+# error conditions
assert_eq 1 2
assert_eq 1 2 "This is my error message"
```
@@ -1250,9 +1218,8 @@ The amount of milliseconds waited.
#### Examples
-Example of sleep for 10 milliseconds"
-
```sh
+# will sleep for 10 milliseconds
time = sleep 10
echo Waited for ${time} milliseconds.
```
diff --git a/duckscript_sdk/Cargo.toml b/duckscript_sdk/Cargo.toml
index e1a3af9..361fe2e 100644
--- a/duckscript_sdk/Cargo.toml
+++ b/duckscript_sdk/Cargo.toml
@@ -24,6 +24,7 @@ include = [
[dependencies]
duckscript = { version = "^0.1", path = "../duckscript" }
+fs_extra = "^1"
home = "^0.5"
rand = "^0.7"
diff --git a/duckscript_sdk/src/sdk/std/alias/help.md b/duckscript_sdk/src/sdk/std/alias/help.md
index abde6b1..25d42a6 100644
--- a/duckscript_sdk/src/sdk/std/alias/help.md
+++ b/duckscript_sdk/src/sdk/std/alias/help.md
@@ -15,9 +15,8 @@ None
#### Examples
-This example creates a new **my_echo** alias that will print the prefix before the requested arguments.
-
```sh
+# This example creates a new **my_echo** alias that will print the prefix before the requested arguments.
alias my_echo echo [ECHO]
# This will print "[ECHO] hello world "
diff --git a/duckscript_sdk/src/sdk/std/echo/help.md b/duckscript_sdk/src/sdk/std/echo/help.md
index 02f26c5..6d30d49 100644
--- a/duckscript_sdk/src/sdk/std/echo/help.md
+++ b/duckscript_sdk/src/sdk/std/echo/help.md
@@ -15,14 +15,10 @@ The amount of arguments printed.
#### Examples
-Print multiple arguments:
-
```sh
+# Print multiple arguments:
echo hello world
-```
-Print multiple spaces between words
-
-```sh
+# Print multiple spaces between words
echo "hello world"
```
diff --git a/duckscript_sdk/src/sdk/std/env/cd/help.md b/duckscript_sdk/src/sdk/std/env/cd/help.md
index 33a4cc9..031b114 100644
--- a/duckscript_sdk/src/sdk/std/env/cd/help.md
+++ b/duckscript_sdk/src/sdk/std/env/cd/help.md
@@ -16,14 +16,10 @@ The new current directory.
#### Examples
-Move to user home directory and store the path in the home variable
-
```sh
+# Move to user home directory and store the path in the home variable
home = cd
-```
-Move to the requested directory
-
-```sh
+# Move to the requested directory
cd ./scripts
```
diff --git a/duckscript_sdk/src/sdk/std/env/pwd/help.md b/duckscript_sdk/src/sdk/std/env/pwd/help.md
index 28c17dd..55a03a9 100644
--- a/duckscript_sdk/src/sdk/std/env/pwd/help.md
+++ b/duckscript_sdk/src/sdk/std/env/pwd/help.md
@@ -14,14 +14,10 @@ The current directory path.
#### Examples
-Print the current directory:
-
```sh
+# Print the current directory:
pwd
-```
-Print and also store the current directory:
-
-```sh
+# Print and also store the current directory:
directory = pwd
```
diff --git a/duckscript_sdk/src/sdk/std/forin/help.md b/duckscript_sdk/src/sdk/std/forin/help.md
index 10f248e..febd028 100644
--- a/duckscript_sdk/src/sdk/std/forin/help.md
+++ b/duckscript_sdk/src/sdk/std/forin/help.md
@@ -24,9 +24,8 @@ None
#### Examples
-Simple example iteration over the list of letters:
-
```sh
+# Simple example iteration over the list of letters:
args = array a b c
for arg in args
@@ -34,11 +33,8 @@ for arg in args
end_for
release args
-```
-Example nested loops:
-
-```sh
+# Example nested loops:
range = array 1 2 3
for i in range
for j in range
diff --git a/duckscript_sdk/src/sdk/std/fs/mod.rs b/duckscript_sdk/src/sdk/std/fs/mod.rs
index f8a0704..16aa203 100755
--- a/duckscript_sdk/src/sdk/std/fs/mod.rs
+++ b/duckscript_sdk/src/sdk/std/fs/mod.rs
@@ -2,6 +2,7 @@ mod basename;
mod canonical;
mod dirname;
mod mkdir;
+mod mv;
mod print;
mod read;
mod rm;
@@ -22,6 +23,7 @@ pub(crate) fn load(commands: &mut Commands, parent: &str) -> Result<(), ScriptEr
commands.set(canonical::create(&package))?;
commands.set(dirname::create(&package))?;
commands.set(mkdir::create(&package))?;
+ commands.set(mv::create(&package))?;
commands.set(print::create(&package))?;
commands.set(read::create(&package))?;
commands.set(rm::create(&package))?;
diff --git a/duckscript_sdk/src/sdk/std/fs/mv/help.md b/duckscript_sdk/src/sdk/std/fs/mv/help.md
new file mode 100644
index 0000000..4889edf
--- /dev/null
+++ b/duckscript_sdk/src/sdk/std/fs/mv/help.md
@@ -0,0 +1,32 @@
+```sh
+var = mv source target
+```
+
+This command moves the requested source path to the target path.
+
+* If the source and target paths define a file, it will move the file as defined.
+* If target path is a directory path, it will move the source file/directory into that target directory path.
+
+All missing parent directories in the target path will be created as needed.
+
+#### Parameters
+
+* The source path to copy
+* The target path
+
+#### Return Value
+
+**true** if the move was successful.
+
+#### Examples
+
+```sh
+# move a single file
+moved = mv ./file1.txt ./file2.txt
+
+# move a single file into the target directory
+moved = mv ./file1.txt ./somedir
+
+# move entire directory into another directory
+moved = mv ./source ./target/subdir
+```
diff --git a/duckscript_sdk/src/sdk/std/fs/mv/mod.rs b/duckscript_sdk/src/sdk/std/fs/mv/mod.rs
new file mode 100755
index 0000000..801b1fc
--- /dev/null
+++ b/duckscript_sdk/src/sdk/std/fs/mv/mod.rs
@@ -0,0 +1,70 @@
+use crate::utils::{io, pckg};
+use duckscript::types::command::{Command, CommandResult};
+use fs_extra::{dir, move_items};
+use std::fs;
+use std::path::Path;
+
+#[cfg(test)]
+#[path = "./mod_test.rs"]
+mod mod_test;
+
+struct CommandImpl {
+ package: String,
+}
+
+impl Command for CommandImpl {
+ fn name(&self) -> String {
+ pckg::concat(&self.package, "MovePath")
+ }
+
+ fn aliases(&self) -> Vec {
+ vec!["mv".to_string()]
+ }
+
+ fn help(&self) -> String {
+ include_str!("help.md").to_string()
+ }
+
+ fn run(&self, arguments: Vec) -> CommandResult {
+ if arguments.len() < 2 {
+ CommandResult::Error("Paths not provided.".to_string())
+ } else {
+ let source_path = Path::new(&arguments[0]);
+
+ if !source_path.exists() {
+ CommandResult::Error(
+ format!("Source path: {} not found.", &arguments[0]).to_string(),
+ )
+ } else {
+ let target_path = Path::new(&arguments[1]);
+ let source_file = source_path.is_file();
+ let target_file = target_path.is_file();
+
+ if source_file && target_file {
+ match fs::rename(&arguments[0], &arguments[1]) {
+ Ok(_) => CommandResult::Continue(Some("true".to_string())),
+ Err(error) => return CommandResult::Error(error.to_string()),
+ }
+ } else {
+ match io::create_directory(&arguments[1]) {
+ Ok(_) => {
+ let options = dir::CopyOptions::new();
+ let from_paths = vec![&arguments[0]];
+ match move_items(&from_paths, &arguments[1], &options) {
+ Ok(_) => CommandResult::Continue(Some("true".to_string())),
+ Err(error) => return CommandResult::Error(error.to_string()),
+ }
+ }
+ Err(error) => CommandResult::Error(error),
+ }
+ }
+ }
+ }
+ }
+}
+
+pub(crate) fn create(package: &str) -> Box {
+ Box::new(CommandImpl {
+ package: package.to_string(),
+ })
+}
diff --git a/duckscript_sdk/src/sdk/std/fs/mv/mod_test.rs b/duckscript_sdk/src/sdk/std/fs/mv/mod_test.rs
new file mode 100644
index 0000000..eb20420
--- /dev/null
+++ b/duckscript_sdk/src/sdk/std/fs/mv/mod_test.rs
@@ -0,0 +1,78 @@
+use super::*;
+use crate::test;
+use crate::test::CommandValidation;
+
+#[test]
+fn common_functions() {
+ test::test_common_command_functions(create(""));
+}
+
+#[test]
+fn run_no_path_provided() {
+ test::run_script_and_fail(vec![create("")], "mv");
+}
+
+#[test]
+fn run_single_path_provided() {
+ test::run_script_and_fail(vec![create("")], "mv a");
+}
+
+#[test]
+fn run_input_path_not_exists() {
+ test::run_script_and_fail(
+ vec![create("")],
+ "mv ./target/_duckscript/mv/not_exists.txt ./target/_duckscript/mv/not_exists/",
+ );
+}
+
+#[test]
+fn run_file_to_file() {
+ let mut path = Path::new("./target/_duckscript/mv/run_file_to_file/1/file1.txt");
+ let result = io::create_empty_file("./target/_duckscript/mv/run_file_to_file/1/file1.txt");
+ assert!(result.is_ok());
+ assert!(path.exists());
+
+ test::run_script_and_validate(vec![create("")], r#"
+ out = mv ./target/_duckscript/mv/run_file_to_file/1/file1.txt ./target/_duckscript/mv/run_file_to_file/2/file2.txt
+ "#,
+ CommandValidation::Match("out".to_string(), "true".to_string()),);
+
+ assert!(!path.exists());
+ path = Path::new("./target/_duckscript/mv/run_file_to_file/2/file2.txt");
+ assert!(path.exists());
+}
+
+#[test]
+fn run_file_to_directory() {
+ let mut path = Path::new("./target/_duckscript/mv/run_file_to_directory/1/file1.txt");
+ let result = io::create_empty_file("./target/_duckscript/mv/run_file_to_directory/1/file1.txt");
+ assert!(result.is_ok());
+ assert!(path.exists());
+
+ test::run_script_and_validate(vec![create("")], r#"
+ out = mv ./target/_duckscript/mv/run_file_to_directory/1/file1.txt ./target/_duckscript/mv/run_file_to_directory/2
+ "#,
+ CommandValidation::Match("out".to_string(), "true".to_string()),);
+
+ assert!(!path.exists());
+ path = Path::new("./target/_duckscript/mv/run_file_to_directory/2/file1.txt");
+ assert!(path.exists());
+}
+
+#[test]
+fn run_directory_to_directory() {
+ let mut path = Path::new("./target/_duckscript/mv/run_directory_to_directory/1/1/file1.txt");
+ let result =
+ io::create_empty_file("./target/_duckscript/mv/run_directory_to_directory/1/1/file1.txt");
+ assert!(result.is_ok());
+ assert!(path.exists());
+
+ test::run_script_and_validate(vec![create("")], r#"
+ out = mv ./target/_duckscript/mv/run_directory_to_directory/1 ./target/_duckscript/mv/run_directory_to_directory/2
+ "#,
+ CommandValidation::Match("out".to_string(), "true".to_string()),);
+
+ assert!(!path.exists());
+ path = Path::new("./target/_duckscript/mv/run_directory_to_directory/2/1/1/file1.txt");
+ assert!(path.exists());
+}
diff --git a/duckscript_sdk/src/sdk/std/function/help.md b/duckscript_sdk/src/sdk/std/function/help.md
index 10c8b9c..bc4b07c 100644
--- a/duckscript_sdk/src/sdk/std/function/help.md
+++ b/duckscript_sdk/src/sdk/std/function/help.md
@@ -37,27 +37,20 @@ The function invocation returns the output provided by the return command.
#### Examples
-Simple example of a function definition which echo 'hello world' and exists.
-
```sh
+# Simple example of a function definition which echo 'hello world' and exists.
+
# function start
function hello_world
-
-echo hello world
-
+ echo hello world
end_function
# function invocation
hello_world
-```
-Example of calling a function and returning a value
-
-```sh
+# Example of calling a function and returning a value
function get_hello_world
-
-return "hello world"
-
+ return "hello world"
end_function
# function invocation
@@ -65,32 +58,24 @@ text = get_hello_world
# this will print "hello world"
echo ${text}
-```
-Example of passing arguments
-
-```sh
+# Example of passing arguments
function print_input
-
-# $1 is set with the value 'hello'
-# $2 is set with the value 'world'
-echo ${1} ${2}
-
+ # $1 is set with the value 'hello'
+ # $2 is set with the value 'world'
+ echo ${1} ${2}
end_function
print_input hello world
-```
-Functions can call other functions
-
-```sh
+# Functions can call other functions
function get_one
-return 1
+ return 1
end_function
function get_number
-number = get_one
-return ${number}
+ number = get_one
+ return ${number}
end_function
output = get_number
diff --git a/duckscript_sdk/src/sdk/std/ifelse/help.md b/duckscript_sdk/src/sdk/std/ifelse/help.md
index 5a74674..0071330 100644
--- a/duckscript_sdk/src/sdk/std/ifelse/help.md
+++ b/duckscript_sdk/src/sdk/std/ifelse/help.md
@@ -45,43 +45,30 @@ None
#### Examples
-Simple example of an if statement that evaluates the argument value as true and echos "in if"
-
```sh
+# Simple example of an if statement that evaluates the argument value as true and echos "in if"
if true
echo in if
end_if
-```
-Example of using **not** command to reverse the output value
-
-```sh
+# Example of using **not** command to reverse the output value
if not false
echo in if
end_if
-```
-Example of an if statement that evaluates the command as true and echos "in if"
-
-```sh
+# Example of an if statement that evaluates the command as true and echos "in if"
if set true
echo in if
end_if
-```
-Example of if condition returning a falsy result and navigation goes to the else block which echos "in else"
-
-```sh
+# Example of if condition returning a falsy result and navigation goes to the else block which echos "in else"
if set false
echo should not be here
else
echo in else
end_if
-```
-Example of if condition returning a falsy result and navigation goes to the elseif block has a truthy condition
-
-```sh
+# Example of if condition returning a falsy result and navigation goes to the elseif block has a truthy condition
if set false
echo should not be here
elseif set true
@@ -89,11 +76,8 @@ elseif set true
else
echo should not be here
end_if
-```
-Nested if example:
-
-```sh
+# Nested if example:
if set false
echo should not be here
elseif set true
diff --git a/duckscript_sdk/src/sdk/std/not/help.md b/duckscript_sdk/src/sdk/std/not/help.md
index 516cc3b..10cde40 100644
--- a/duckscript_sdk/src/sdk/std/not/help.md
+++ b/duckscript_sdk/src/sdk/std/not/help.md
@@ -28,19 +28,15 @@ The switched value of the input.
#### Examples
-Simple example of converting true/false values
-
```sh
+# Simple example of converting true/false values
is_false = not true
echo is false: ${is_false}
is_true = not false
echo is true: ${is_true}
-```
-Example of converting command output value
-
-```sh
+# Example of converting command output value
is_false = not set true
echo is false: ${is_false}
diff --git a/duckscript_sdk/src/sdk/std/process/exec/help.md b/duckscript_sdk/src/sdk/std/process/exec/help.md
index 7109fe5..8133455 100644
--- a/duckscript_sdk/src/sdk/std/process/exec/help.md
+++ b/duckscript_sdk/src/sdk/std/process/exec/help.md
@@ -26,15 +26,11 @@ Optionally a base name to access the process stout, stderr and exit code informa
#### Examples
-Example of running a command and flushing its output to the parent process.
-
```sh
+# Example of running a command and flushing its output to the parent process.
exec echo hello world
-```
-Example of running a command and storing its output.
-
-```sh
+# Example of running a command and storing its output.
output = exec echo hello world
stdout = set ${output.stdout}
diff --git a/duckscript_sdk/src/sdk/std/process/exit/help.md b/duckscript_sdk/src/sdk/std/process/exit/help.md
index 8549666..00b6411 100644
--- a/duckscript_sdk/src/sdk/std/process/exit/help.md
+++ b/duckscript_sdk/src/sdk/std/process/exit/help.md
@@ -14,14 +14,10 @@ The exit code.
#### Examples
-Example of exit with code '0'
-
```sh
+# exit with code '0'
code = exit
-```
-Example of exit with error code '1'
-
-```sh
+# exit with code '1'
code = exit 1
```
diff --git a/duckscript_sdk/src/sdk/std/set/help.md b/duckscript_sdk/src/sdk/std/set/help.md
index f224c3a..e56bebe 100644
--- a/duckscript_sdk/src/sdk/std/set/help.md
+++ b/duckscript_sdk/src/sdk/std/set/help.md
@@ -15,14 +15,10 @@ The first command argument.
#### Examples
-Return a simple text value:
-
```sh
+# Return simple 'hello' text value
var = set hello
-```
-Return an expanded value:
-
-```sh
+# Return expanded value: 'home: ....'
var = set "home: ${HOME}"
```
diff --git a/duckscript_sdk/src/sdk/std/test/assert/help.md b/duckscript_sdk/src/sdk/std/test/assert/help.md
index 5da8c25..e33c23f 100644
--- a/duckscript_sdk/src/sdk/std/test/assert/help.md
+++ b/duckscript_sdk/src/sdk/std/test/assert/help.md
@@ -24,20 +24,16 @@ It is considered falsy and will exist with an error.
#### Examples
-Valid condition:
-
```sh
+# valid conditions
assert ok
assert true
assert yes
value = set "some text"
assert ${value}
-```
-Error example:
-
-```sh
+# error conditions
assert
assert false
assert 0
diff --git a/duckscript_sdk/src/sdk/std/test/assert_eq/help.md b/duckscript_sdk/src/sdk/std/test/assert_eq/help.md
index e7d256c..3c4b915 100644
--- a/duckscript_sdk/src/sdk/std/test/assert_eq/help.md
+++ b/duckscript_sdk/src/sdk/std/test/assert_eq/help.md
@@ -16,19 +16,15 @@ If they are not, the command will exist with an error.
#### Examples
-Valid condition:
-
```sh
+# valid conditions
assert_eq yes yes
assert_eq false false
value = set "some text"
assert_eq ${value} "some text"
-```
-Error example:
-
-```sh
+# error conditions
assert_eq 1 2
assert_eq 1 2 "This is my error message"
```
diff --git a/duckscript_sdk/src/sdk/std/thread/sleep/help.md b/duckscript_sdk/src/sdk/std/thread/sleep/help.md
index dc6e47b..5aff3d0 100644
--- a/duckscript_sdk/src/sdk/std/thread/sleep/help.md
+++ b/duckscript_sdk/src/sdk/std/thread/sleep/help.md
@@ -15,9 +15,8 @@ The amount of milliseconds waited.
#### Examples
-Example of sleep for 10 milliseconds"
-
```sh
+# will sleep for 10 milliseconds
time = sleep 10
echo Waited for ${time} milliseconds.
```
diff --git a/duckscript_sdk/src/utils/io.rs b/duckscript_sdk/src/utils/io.rs
index 71b4baa..55fe2ce 100644
--- a/duckscript_sdk/src/utils/io.rs
+++ b/duckscript_sdk/src/utils/io.rs
@@ -51,6 +51,10 @@ pub(crate) fn create_directory(directory: &str) -> Result<(), String> {
}
fn create_directory_for_path(directory_path: &Path) -> Result<(), String> {
+ if directory_path.is_dir() && directory_path.exists() {
+ return Ok(());
+ }
+
match create_dir_all(&directory_path) {
Ok(_) => Ok(()),
Err(error) => Err(error.to_string()),