From c039360eaa991cb21182fc4f1ae7619f84bfa7c5 Mon Sep 17 00:00:00 2001 From: sagie gur ari Date: Fri, 31 Jul 2020 09:58:27 +0000 Subject: [PATCH] release --- CHANGELOG.md | 2 +- docs/api/duckscript_sdk/source-files.js | 2 +- .../sdk/std/collections/mod.rs.html | 6 + .../sdk/std/json/encode/mod.rs.html | 333 ++++++++++++++++++ .../duckscriptsdk/sdk/std/json/mod.rs.html | 47 +++ .../sdk/std/json/parse/mod.rs.html | 231 ++++++++++++ .../src/duckscriptsdk/sdk/std/mod.rs.html | 4 + .../sdk/std/test/test_directory/mod.rs.html | 2 +- .../sdk/std/test/test_file/mod.rs.html | 10 +- .../src/duckscriptsdk/sdk/std/var/mod.rs.html | 4 + .../sdk/std/var/unset_all_vars/mod.rs.html | 129 +++++++ .../src/duckscriptsdk/types/command.rs.html | 62 ++++ duckscript_cli/Cargo.toml | 4 +- duckscript_sdk/Cargo.toml | 2 +- 14 files changed, 831 insertions(+), 7 deletions(-) create mode 100644 docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/json/encode/mod.rs.html create mode 100644 docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/json/mod.rs.html create mode 100644 docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/json/parse/mod.rs.html create mode 100644 docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/var/unset_all_vars/mod.rs.html diff --git a/CHANGELOG.md b/CHANGELOG.md index 78763d2..2a4f926 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## CHANGELOG -### v0.6.4 +### v0.6.4 (2020-07-31) * New json_encode command #124 * New json_parse command #124 diff --git a/docs/api/duckscript_sdk/source-files.js b/docs/api/duckscript_sdk/source-files.js index 3e505b0..e5327f2 100644 --- a/docs/api/duckscript_sdk/source-files.js +++ b/docs/api/duckscript_sdk/source-files.js @@ -1,3 +1,3 @@ var N = null;var sourcesIndex = {}; -sourcesIndex["duckscriptsdk"] = {"name":"","dirs":[{"name":"sdk","dirs":[{"name":"internal","dirs":[{"name":"sdkdocs","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"std","dirs":[{"name":"collections","dirs":[{"name":"array","files":["mod.rs"]},{"name":"array_clear","files":["mod.rs"]},{"name":"array_concat","files":["mod.rs"]},{"name":"array_contains","files":["mod.rs"]},{"name":"array_get","files":["mod.rs"]},{"name":"array_is_empty","files":["mod.rs"]},{"name":"array_join","files":["mod.rs"]},{"name":"array_length","files":["mod.rs"]},{"name":"array_pop","files":["mod.rs"]},{"name":"array_push","files":["mod.rs"]},{"name":"array_remove","files":["mod.rs"]},{"name":"array_set","files":["mod.rs"]},{"name":"is_array","files":["mod.rs"]},{"name":"is_map","files":["mod.rs"]},{"name":"is_set","files":["mod.rs"]},{"name":"map","files":["mod.rs"]},{"name":"map_clear","files":["mod.rs"]},{"name":"map_contains_key","files":["mod.rs"]},{"name":"map_contains_value","files":["mod.rs"]},{"name":"map_get","files":["mod.rs"]},{"name":"map_is_empty","files":["mod.rs"]},{"name":"map_keys","files":["mod.rs"]},{"name":"map_load_properties","files":["mod.rs"]},{"name":"map_put","files":["mod.rs"]},{"name":"map_remove","files":["mod.rs"]},{"name":"map_size","files":["mod.rs"]},{"name":"map_to_properties","files":["mod.rs"]},{"name":"range","files":["mod.rs"]},{"name":"read_properties","files":["mod.rs"]},{"name":"set","files":["mod.rs"]},{"name":"set_clear","files":["mod.rs"]},{"name":"set_contains","files":["mod.rs"]},{"name":"set_from_array","files":["mod.rs"]},{"name":"set_is_empty","files":["mod.rs"]},{"name":"set_put","files":["mod.rs"]},{"name":"set_remove","files":["mod.rs"]},{"name":"set_size","files":["mod.rs"]},{"name":"set_to_array","files":["mod.rs"]},{"name":"write_properties","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"debug","dirs":[{"name":"duckscript_sdk_version","files":["mod.rs"]},{"name":"duckscript_version","files":["mod.rs"]},{"name":"dump_instructions","files":["mod.rs"]},{"name":"dump_state","files":["mod.rs"]},{"name":"dump_variables","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"echo","files":["mod.rs"]},{"name":"env","dirs":[{"name":"cpu_count","files":["mod.rs"]},{"name":"env_to_map","files":["mod.rs"]},{"name":"get_env","files":["mod.rs"]},{"name":"get_home_dir","files":["mod.rs"]},{"name":"get_user_name","files":["mod.rs"]},{"name":"is_windows","files":["mod.rs"]},{"name":"os_family","files":["mod.rs"]},{"name":"os_name","files":["mod.rs"]},{"name":"os_release","files":["mod.rs"]},{"name":"os_version","files":["mod.rs"]},{"name":"print_current_directory","files":["mod.rs"]},{"name":"print_env","files":["mod.rs"]},{"name":"set_current_directory","files":["mod.rs"]},{"name":"set_env","files":["mod.rs"]},{"name":"uname","files":["mod.rs"]},{"name":"unset","files":["mod.rs"]},{"name":"which","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"eval","files":["mod.rs"]},{"name":"flowcontrol","dirs":[{"name":"end","files":["mod.rs"]},{"name":"forin","files":["mod.rs"]},{"name":"function","files":["mod.rs"]},{"name":"goto","files":["mod.rs"]},{"name":"ifelse","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"fs","dirs":[{"name":"append","files":["mod.rs"]},{"name":"basename","files":["mod.rs"]},{"name":"canonical","files":["mod.rs"]},{"name":"cp","files":["mod.rs"]},{"name":"dirname","files":["mod.rs"]},{"name":"exists","files":["mod.rs"]},{"name":"get_last_modified_time","files":["mod.rs"]},{"name":"glob_array","files":["mod.rs"]},{"name":"is_directory","files":["mod.rs"]},{"name":"is_file","files":["mod.rs"]},{"name":"is_path_newer","files":["mod.rs"]},{"name":"is_readonly","files":["mod.rs"]},{"name":"list","files":["mod.rs"]},{"name":"mkdir","files":["mod.rs"]},{"name":"mv","files":["mod.rs"]},{"name":"print","files":["mod.rs"]},{"name":"read_bytes","files":["mod.rs"]},{"name":"read_text","files":["mod.rs"]},{"name":"rm","files":["mod.rs"]},{"name":"rmdir","files":["mod.rs"]},{"name":"set_mode","files":["mod.rs"]},{"name":"set_mode_glob","files":["mod.rs"]},{"name":"temp_dir","files":["mod.rs"]},{"name":"temp_file","files":["mod.rs"]},{"name":"touch","files":["mod.rs"]},{"name":"write_bytes","files":["mod.rs"]},{"name":"write_text","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"is_defined","files":["mod.rs"]},{"name":"lib","dirs":[{"name":"alias","dirs":[{"name":"set","files":["mod.rs"]},{"name":"unset","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"command","dirs":[{"name":"remove","files":["mod.rs"]}],"files":["mod.rs"]}],"files":["mod.rs"]},{"name":"man","files":["mod.rs"]},{"name":"math","dirs":[{"name":"calc","files":["mod.rs"]},{"name":"greater_than","files":["mod.rs"]},{"name":"less_than","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"net","dirs":[{"name":"ftp","dirs":[{"name":"get","files":["mod.rs"]},{"name":"get_in_memory","files":["mod.rs"]},{"name":"list","files":["mod.rs"]},{"name":"nlst","files":["mod.rs"]},{"name":"put","files":["mod.rs"]},{"name":"put_in_memory","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"hostname","files":["mod.rs"]},{"name":"http_client","files":["mod.rs"]},{"name":"wget","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"noop","files":["mod.rs"]},{"name":"not","files":["mod.rs"]},{"name":"on_error","dirs":[{"name":"exit_on_error","files":["mod.rs"]},{"name":"get_last_error","files":["mod.rs"]},{"name":"get_last_error_line","files":["mod.rs"]},{"name":"get_last_error_source","files":["mod.rs"]},{"name":"on_error","files":["mod.rs"]},{"name":"set_error","files":["mod.rs"]},{"name":"trigger_error","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"process","dirs":[{"name":"exec","files":["mod.rs"]},{"name":"exit","files":["mod.rs"]},{"name":"process_id","files":["mod.rs"]},{"name":"spawn","files":["mod.rs"]},{"name":"watchdog","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"read","files":["mod.rs"]},{"name":"release","files":["mod.rs"]},{"name":"scope","dirs":[{"name":"clear","files":["mod.rs"]},{"name":"pop_stack","files":["mod.rs"]},{"name":"push_stack","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"string","dirs":[{"name":"base64","files":["mod.rs"]},{"name":"base64_decode","files":["mod.rs"]},{"name":"base64_encode","files":["mod.rs"]},{"name":"bytes_to_string","files":["mod.rs"]},{"name":"concat","files":["mod.rs"]},{"name":"contains","files":["mod.rs"]},{"name":"ends_with","files":["mod.rs"]},{"name":"equals","files":["mod.rs"]},{"name":"indexof","files":["mod.rs"]},{"name":"is_empty","files":["mod.rs"]},{"name":"last_indexof","files":["mod.rs"]},{"name":"length","files":["mod.rs"]},{"name":"replace","files":["mod.rs"]},{"name":"split","files":["mod.rs"]},{"name":"starts_with","files":["mod.rs"]},{"name":"string_to_bytes","files":["mod.rs"]},{"name":"substring","files":["mod.rs"]},{"name":"trim","files":["mod.rs"]},{"name":"trim_end","files":["mod.rs"]},{"name":"trim_start","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"test","dirs":[{"name":"assert","files":["mod.rs"]},{"name":"assert_eq","files":["mod.rs"]},{"name":"assert_error","files":["mod.rs"]},{"name":"assert_fail","files":["mod.rs"]},{"name":"assert_false","files":["mod.rs"]},{"name":"test_directory","files":["mod.rs"]},{"name":"test_file","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"thread","dirs":[{"name":"sleep","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"time","dirs":[{"name":"current_time","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"var","dirs":[{"name":"get_all_var_names","files":["mod.rs"]},{"name":"get_by_name","files":["mod.rs"]},{"name":"set","files":["mod.rs"]},{"name":"set_by_name","files":["mod.rs"]},{"name":"unset","files":["mod.rs"]}],"files":["mod.rs"]}],"files":["mod.rs"]}],"files":["mod.rs"]},{"name":"types","files":["command.rs","mod.rs","scope.rs"]},{"name":"utils","files":["annotation.rs","condition.rs","eval.rs","exec.rs","flags.rs","instruction_query.rs","io.rs","mod.rs","pckg.rs","scope.rs","state.rs"]}],"files":["lib.rs"]}; +sourcesIndex["duckscriptsdk"] = {"name":"","dirs":[{"name":"sdk","dirs":[{"name":"internal","dirs":[{"name":"sdkdocs","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"std","dirs":[{"name":"collections","dirs":[{"name":"array","files":["mod.rs"]},{"name":"array_clear","files":["mod.rs"]},{"name":"array_concat","files":["mod.rs"]},{"name":"array_contains","files":["mod.rs"]},{"name":"array_get","files":["mod.rs"]},{"name":"array_is_empty","files":["mod.rs"]},{"name":"array_join","files":["mod.rs"]},{"name":"array_length","files":["mod.rs"]},{"name":"array_pop","files":["mod.rs"]},{"name":"array_push","files":["mod.rs"]},{"name":"array_remove","files":["mod.rs"]},{"name":"array_set","files":["mod.rs"]},{"name":"is_array","files":["mod.rs"]},{"name":"is_map","files":["mod.rs"]},{"name":"is_set","files":["mod.rs"]},{"name":"map","files":["mod.rs"]},{"name":"map_clear","files":["mod.rs"]},{"name":"map_contains_key","files":["mod.rs"]},{"name":"map_contains_value","files":["mod.rs"]},{"name":"map_get","files":["mod.rs"]},{"name":"map_is_empty","files":["mod.rs"]},{"name":"map_keys","files":["mod.rs"]},{"name":"map_load_properties","files":["mod.rs"]},{"name":"map_put","files":["mod.rs"]},{"name":"map_remove","files":["mod.rs"]},{"name":"map_size","files":["mod.rs"]},{"name":"map_to_properties","files":["mod.rs"]},{"name":"range","files":["mod.rs"]},{"name":"read_properties","files":["mod.rs"]},{"name":"set","files":["mod.rs"]},{"name":"set_clear","files":["mod.rs"]},{"name":"set_contains","files":["mod.rs"]},{"name":"set_from_array","files":["mod.rs"]},{"name":"set_is_empty","files":["mod.rs"]},{"name":"set_put","files":["mod.rs"]},{"name":"set_remove","files":["mod.rs"]},{"name":"set_size","files":["mod.rs"]},{"name":"set_to_array","files":["mod.rs"]},{"name":"write_properties","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"debug","dirs":[{"name":"duckscript_sdk_version","files":["mod.rs"]},{"name":"duckscript_version","files":["mod.rs"]},{"name":"dump_instructions","files":["mod.rs"]},{"name":"dump_state","files":["mod.rs"]},{"name":"dump_variables","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"echo","files":["mod.rs"]},{"name":"env","dirs":[{"name":"cpu_count","files":["mod.rs"]},{"name":"env_to_map","files":["mod.rs"]},{"name":"get_env","files":["mod.rs"]},{"name":"get_home_dir","files":["mod.rs"]},{"name":"get_user_name","files":["mod.rs"]},{"name":"is_windows","files":["mod.rs"]},{"name":"os_family","files":["mod.rs"]},{"name":"os_name","files":["mod.rs"]},{"name":"os_release","files":["mod.rs"]},{"name":"os_version","files":["mod.rs"]},{"name":"print_current_directory","files":["mod.rs"]},{"name":"print_env","files":["mod.rs"]},{"name":"set_current_directory","files":["mod.rs"]},{"name":"set_env","files":["mod.rs"]},{"name":"uname","files":["mod.rs"]},{"name":"unset","files":["mod.rs"]},{"name":"which","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"eval","files":["mod.rs"]},{"name":"flowcontrol","dirs":[{"name":"end","files":["mod.rs"]},{"name":"forin","files":["mod.rs"]},{"name":"function","files":["mod.rs"]},{"name":"goto","files":["mod.rs"]},{"name":"ifelse","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"fs","dirs":[{"name":"append","files":["mod.rs"]},{"name":"basename","files":["mod.rs"]},{"name":"canonical","files":["mod.rs"]},{"name":"cp","files":["mod.rs"]},{"name":"dirname","files":["mod.rs"]},{"name":"exists","files":["mod.rs"]},{"name":"get_last_modified_time","files":["mod.rs"]},{"name":"glob_array","files":["mod.rs"]},{"name":"is_directory","files":["mod.rs"]},{"name":"is_file","files":["mod.rs"]},{"name":"is_path_newer","files":["mod.rs"]},{"name":"is_readonly","files":["mod.rs"]},{"name":"list","files":["mod.rs"]},{"name":"mkdir","files":["mod.rs"]},{"name":"mv","files":["mod.rs"]},{"name":"print","files":["mod.rs"]},{"name":"read_bytes","files":["mod.rs"]},{"name":"read_text","files":["mod.rs"]},{"name":"rm","files":["mod.rs"]},{"name":"rmdir","files":["mod.rs"]},{"name":"set_mode","files":["mod.rs"]},{"name":"set_mode_glob","files":["mod.rs"]},{"name":"temp_dir","files":["mod.rs"]},{"name":"temp_file","files":["mod.rs"]},{"name":"touch","files":["mod.rs"]},{"name":"write_bytes","files":["mod.rs"]},{"name":"write_text","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"is_defined","files":["mod.rs"]},{"name":"json","dirs":[{"name":"encode","files":["mod.rs"]},{"name":"parse","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"lib","dirs":[{"name":"alias","dirs":[{"name":"set","files":["mod.rs"]},{"name":"unset","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"command","dirs":[{"name":"remove","files":["mod.rs"]}],"files":["mod.rs"]}],"files":["mod.rs"]},{"name":"man","files":["mod.rs"]},{"name":"math","dirs":[{"name":"calc","files":["mod.rs"]},{"name":"greater_than","files":["mod.rs"]},{"name":"less_than","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"net","dirs":[{"name":"ftp","dirs":[{"name":"get","files":["mod.rs"]},{"name":"get_in_memory","files":["mod.rs"]},{"name":"list","files":["mod.rs"]},{"name":"nlst","files":["mod.rs"]},{"name":"put","files":["mod.rs"]},{"name":"put_in_memory","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"hostname","files":["mod.rs"]},{"name":"http_client","files":["mod.rs"]},{"name":"wget","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"noop","files":["mod.rs"]},{"name":"not","files":["mod.rs"]},{"name":"on_error","dirs":[{"name":"exit_on_error","files":["mod.rs"]},{"name":"get_last_error","files":["mod.rs"]},{"name":"get_last_error_line","files":["mod.rs"]},{"name":"get_last_error_source","files":["mod.rs"]},{"name":"on_error","files":["mod.rs"]},{"name":"set_error","files":["mod.rs"]},{"name":"trigger_error","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"process","dirs":[{"name":"exec","files":["mod.rs"]},{"name":"exit","files":["mod.rs"]},{"name":"process_id","files":["mod.rs"]},{"name":"spawn","files":["mod.rs"]},{"name":"watchdog","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"read","files":["mod.rs"]},{"name":"release","files":["mod.rs"]},{"name":"scope","dirs":[{"name":"clear","files":["mod.rs"]},{"name":"pop_stack","files":["mod.rs"]},{"name":"push_stack","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"string","dirs":[{"name":"base64","files":["mod.rs"]},{"name":"base64_decode","files":["mod.rs"]},{"name":"base64_encode","files":["mod.rs"]},{"name":"bytes_to_string","files":["mod.rs"]},{"name":"concat","files":["mod.rs"]},{"name":"contains","files":["mod.rs"]},{"name":"ends_with","files":["mod.rs"]},{"name":"equals","files":["mod.rs"]},{"name":"indexof","files":["mod.rs"]},{"name":"is_empty","files":["mod.rs"]},{"name":"last_indexof","files":["mod.rs"]},{"name":"length","files":["mod.rs"]},{"name":"replace","files":["mod.rs"]},{"name":"split","files":["mod.rs"]},{"name":"starts_with","files":["mod.rs"]},{"name":"string_to_bytes","files":["mod.rs"]},{"name":"substring","files":["mod.rs"]},{"name":"trim","files":["mod.rs"]},{"name":"trim_end","files":["mod.rs"]},{"name":"trim_start","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"test","dirs":[{"name":"assert","files":["mod.rs"]},{"name":"assert_eq","files":["mod.rs"]},{"name":"assert_error","files":["mod.rs"]},{"name":"assert_fail","files":["mod.rs"]},{"name":"assert_false","files":["mod.rs"]},{"name":"test_directory","files":["mod.rs"]},{"name":"test_file","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"thread","dirs":[{"name":"sleep","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"time","dirs":[{"name":"current_time","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"var","dirs":[{"name":"get_all_var_names","files":["mod.rs"]},{"name":"get_by_name","files":["mod.rs"]},{"name":"set","files":["mod.rs"]},{"name":"set_by_name","files":["mod.rs"]},{"name":"unset","files":["mod.rs"]},{"name":"unset_all_vars","files":["mod.rs"]}],"files":["mod.rs"]}],"files":["mod.rs"]}],"files":["mod.rs"]},{"name":"types","files":["command.rs","mod.rs","scope.rs"]},{"name":"utils","files":["annotation.rs","condition.rs","eval.rs","exec.rs","flags.rs","instruction_query.rs","io.rs","mod.rs","pckg.rs","scope.rs","state.rs"]}],"files":["lib.rs"]}; createSourceSidebar(); diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/collections/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/collections/mod.rs.html index 6be5039..5a6a15f 100644 --- a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/collections/mod.rs.html +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/collections/mod.rs.html @@ -89,6 +89,9 @@ 89 90 91 +92 +93 +94
 pub(crate) mod array;
 mod array_clear;
@@ -130,6 +133,7 @@
 mod set_to_array;
 mod write_properties;
 
+use crate::types::command::create_doc_only_command;
 use crate::utils::pckg;
 use duckscript::types::command::Commands;
 use duckscript::types::error::ScriptError;
@@ -139,6 +143,8 @@
 pub(crate) fn load(commands: &mut Commands, parent: &str) -> Result<(), ScriptError> {
     let package = pckg::concat(parent, PACKAGE);
 
+    commands.set(create_doc_only_command(&package, include_str!("help.md")))?;
+
     commands.set(array::create(&package))?;
     commands.set(array_clear::create(&package))?;
     commands.set(array_concat::create(&package)?)?;
diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/json/encode/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/json/encode/mod.rs.html
new file mode 100644
index 0000000..169d9c5
--- /dev/null
+++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/json/encode/mod.rs.html
@@ -0,0 +1,333 @@
+mod.rs.html -- source
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+
+use crate::sdk::std::json::OBJECT_VALUE;
+use crate::utils::pckg;
+use duckscript::types::command::{Command, CommandResult, Commands};
+use duckscript::types::instruction::Instruction;
+use duckscript::types::runtime::StateValue;
+use serde_json::map::Map;
+use serde_json::Value;
+use std::collections::{HashMap, HashSet};
+
+#[cfg(test)]
+#[path = "./mod_test.rs"]
+mod mod_test;
+
+fn encode_array(name: &str, values: &HashMap<&str, &str>) -> Result<Value, String> {
+    match values.get(format!("{}.length", name).as_str()) {
+        Some(length_str) => match length_str.parse::<usize>() {
+            Ok(length) => {
+                let mut json_vec = vec![];
+
+                for index in 0..length {
+                    let array_item_name = format!("{}[{}]", name, index);
+                    match encode_any(&array_item_name, values) {
+                        Ok(array_item) => json_vec.push(array_item),
+                        Err(error) => return Err(error),
+                    }
+                }
+
+                Ok(Value::Array(json_vec))
+            }
+            Err(error) => Err(error.to_string()),
+        },
+        None => Err(format!(
+            "{} is not a valid JSON array, missing length attribute.",
+            name
+        )),
+    }
+}
+
+fn encode_object(name: &str, values: &HashMap<&str, &str>) -> Result<Value, String> {
+    let child_prefix = format!("{}.", name);
+    let child_prefix_end = child_prefix.len() - 1;
+    let mut children: HashSet<&str> = HashSet::new();
+
+    for (key, _) in values {
+        if key.starts_with(&child_prefix) {
+            let last_index = key.rfind('.').unwrap();
+
+            if last_index == child_prefix_end {
+                let array_key_end = key.rfind("[").unwrap_or(0);
+                let next_key = if array_key_end > last_index && key.rfind("]").is_some() {
+                    &key[0..array_key_end]
+                } else {
+                    key
+                };
+                children.insert(next_key);
+            }
+        }
+    }
+
+    let mut object = Map::new();
+    let prefix_length = name.len() + 1;
+    for key in children {
+        match encode_any(key, values) {
+            Ok(json_value) => {
+                let child_key = &key[prefix_length..];
+                object.insert(child_key.to_string(), json_value);
+                ()
+            }
+            Err(error) => return Err(error),
+        }
+    }
+
+    Ok(Value::Object(object))
+}
+
+fn encode_any(name: &str, values: &HashMap<&str, &str>) -> Result<Value, String> {
+    match values.get(name) {
+        Some(value) => {
+            if *value == OBJECT_VALUE {
+                encode_object(name, values)
+            } else {
+                Ok(Value::String(value.to_string()))
+            }
+        }
+        None => {
+            if values.contains_key(format!("{}.length", name).as_str()) {
+                encode_array(name, values)
+            } else {
+                Ok(Value::Null)
+            }
+        }
+    }
+}
+
+fn encode(name: &str, variables: &HashMap<String, String>) -> Result<String, String> {
+    let mut object_variables: HashMap<&str, &str> = HashMap::new();
+
+    for (key, value) in variables {
+        if key == name || key.starts_with(name) {
+            object_variables.insert(key, value);
+        }
+    }
+
+    if object_variables.is_empty() {
+        Ok("".to_string())
+    } else {
+        match encode_any(name, &object_variables) {
+            Ok(value) => Ok(value.to_string()),
+            Err(error) => Err(error),
+        }
+    }
+}
+
+#[derive(Clone)]
+pub(crate) struct CommandImpl {
+    package: String,
+}
+
+impl Command for CommandImpl {
+    fn name(&self) -> String {
+        pckg::concat(&self.package, "Encode")
+    }
+
+    fn aliases(&self) -> Vec<String> {
+        vec!["json_encode".to_string()]
+    }
+
+    fn help(&self) -> String {
+        include_str!("help.md").to_string()
+    }
+
+    fn clone_and_box(&self) -> Box<dyn Command> {
+        Box::new((*self).clone())
+    }
+
+    fn requires_context(&self) -> bool {
+        true
+    }
+
+    fn run_with_context(
+        &self,
+        arguments: Vec<String>,
+        _state: &mut HashMap<String, StateValue>,
+        variables: &mut HashMap<String, String>,
+        _output_variable: Option<String>,
+        _instructions: &Vec<Instruction>,
+        _commands: &mut Commands,
+        _line: usize,
+    ) -> CommandResult {
+        if arguments.is_empty() {
+            CommandResult::Error("No JSON root variable name provided.".to_string())
+        } else {
+            match encode(&arguments[0], variables) {
+                Ok(output) => CommandResult::Continue(Some(output)),
+                Err(error) => CommandResult::Error(error),
+            }
+        }
+    }
+}
+
+pub(crate) fn create(package: &str) -> Box<dyn Command> {
+    Box::new(CommandImpl {
+        package: package.to_string(),
+    })
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/json/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/json/mod.rs.html new file mode 100644 index 0000000..7c22914 --- /dev/null +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/json/mod.rs.html @@ -0,0 +1,47 @@ +mod.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+
+mod encode;
+mod parse;
+
+use crate::types::command::create_doc_only_command;
+use crate::utils::pckg;
+use duckscript::types::command::Commands;
+use duckscript::types::error::ScriptError;
+
+static PACKAGE: &str = "json";
+
+pub(crate) static OBJECT_VALUE: &str = "[OBJECT]";
+
+pub(crate) fn load(commands: &mut Commands, parent: &str) -> Result<(), ScriptError> {
+    let package = pckg::concat(parent, PACKAGE);
+
+    commands.set(create_doc_only_command(&package, include_str!("help.md")))?;
+
+    commands.set(encode::create(&package))?;
+    commands.set(parse::create(&package))?;
+
+    Ok(())
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/json/parse/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/json/parse/mod.rs.html new file mode 100644 index 0000000..052022c --- /dev/null +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/json/parse/mod.rs.html @@ -0,0 +1,231 @@ +mod.rs.html -- source
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+
+use crate::sdk::std::json::OBJECT_VALUE;
+use crate::utils::pckg;
+use duckscript::types::command::{Command, CommandResult, Commands};
+use duckscript::types::instruction::Instruction;
+use duckscript::types::runtime::StateValue;
+use serde_json::{Result, Value};
+use std::collections::HashMap;
+
+#[cfg(test)]
+#[path = "./mod_test.rs"]
+mod mod_test;
+
+fn parse_json(data: &str) -> Result<Value> {
+    let value: Value = serde_json::from_str(data)?;
+
+    Ok(value)
+}
+
+fn create_variables(data: Value, name: &str, variables: &mut HashMap<String, String>) {
+    match data {
+        Value::Null => variables.remove(name),
+        Value::Bool(value) => variables.insert(name.to_string(), value.to_string()),
+        Value::Number(value) => variables.insert(name.to_string(), value.to_string()),
+        Value::String(value) => variables.insert(name.to_string(), value),
+        Value::Array(list) => {
+            let mut index = 0;
+            for item in list {
+                let child_name = format!("{}[{}]", name, index);
+                create_variables(item, &child_name, variables);
+                index = index + 1;
+            }
+            variables.insert(format!("{}.length", name), index.to_string());
+
+            None
+        }
+        Value::Object(map) => {
+            variables.insert(name.to_string(), OBJECT_VALUE.to_string());
+
+            for (key, value) in map {
+                let child_name = format!("{}.{}", name, key);
+                create_variables(value, &child_name, variables);
+            }
+
+            None
+        }
+    };
+}
+
+#[derive(Clone)]
+pub(crate) struct CommandImpl {
+    package: String,
+}
+
+impl Command for CommandImpl {
+    fn name(&self) -> String {
+        pckg::concat(&self.package, "Parse")
+    }
+
+    fn aliases(&self) -> Vec<String> {
+        vec!["json_parse".to_string()]
+    }
+
+    fn help(&self) -> String {
+        include_str!("help.md").to_string()
+    }
+
+    fn clone_and_box(&self) -> Box<dyn Command> {
+        Box::new((*self).clone())
+    }
+
+    fn requires_context(&self) -> bool {
+        true
+    }
+
+    fn run_with_context(
+        &self,
+        arguments: Vec<String>,
+        _state: &mut HashMap<String, StateValue>,
+        variables: &mut HashMap<String, String>,
+        output_variable: Option<String>,
+        _instructions: &Vec<Instruction>,
+        _commands: &mut Commands,
+        _line: usize,
+    ) -> CommandResult {
+        if arguments.is_empty() {
+            CommandResult::Error("No JSON string provided.".to_string())
+        } else {
+            match parse_json(&arguments[0]) {
+                Ok(data) => {
+                    let output = match output_variable {
+                        Some(name) => {
+                            create_variables(data, &name, variables);
+
+                            match variables.get(&name) {
+                                Some(value) => Some(value.to_string()),
+                                None => None,
+                            }
+                        }
+                        None => Some("true".to_string()),
+                    };
+
+                    CommandResult::Continue(output)
+                }
+                Err(error) => CommandResult::Error(error.to_string()),
+            }
+        }
+    }
+}
+
+pub(crate) fn create(package: &str) -> Box<dyn Command> {
+    Box::new(CommandImpl {
+        package: package.to_string(),
+    })
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/mod.rs.html index 82722af..7251fd2 100644 --- a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/mod.rs.html +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/mod.rs.html @@ -57,6 +57,8 @@ 57 58 59 +60 +61
 pub(crate) mod collections;
 mod debug;
@@ -66,6 +68,7 @@
 mod flowcontrol;
 mod fs;
 mod is_defined;
+mod json;
 mod lib;
 mod man;
 mod math;
@@ -103,6 +106,7 @@
     env::load(commands, PACKAGE)?;
     flowcontrol::load(commands, PACKAGE)?;
     fs::load(commands, PACKAGE)?;
+    json::load(commands, PACKAGE)?;
     lib::load(commands, PACKAGE)?;
     math::load(commands, PACKAGE)?;
     net::load(commands, PACKAGE)?;
diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/test/test_directory/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/test/test_directory/mod.rs.html
index cfc2d65..3aebc2a 100644
--- a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/test/test_directory/mod.rs.html
+++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/test/test_directory/mod.rs.html
@@ -184,7 +184,7 @@
 
                     let test_script = format!(
                         r#"
-result = std::test::TestFile {} {}
+result = test_file {} {}
 assert result
 "#,
                         &file, &test_name
diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/test/test_file/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/test/test_file/mod.rs.html
index 32b8316..eaf9a0d 100644
--- a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/test/test_file/mod.rs.html
+++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/test/test_file/mod.rs.html
@@ -143,6 +143,10 @@
 143
 144
 145
+146
+147
+148
+149
 
 use crate::utils::pckg;
 use duckscript::types::command::{Command, CommandResult, Commands};
@@ -176,8 +180,12 @@
         pckg::concat(&self.package, "TestFile")
     }
 
+    fn aliases(&self) -> Vec<String> {
+        vec!["test_file".to_string()]
+    }
+
     fn help(&self) -> String {
-        "".to_string()
+        include_str!("help.md").to_string()
     }
 
     fn clone_and_box(&self) -> Box<dyn Command> {
diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/var/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/var/mod.rs.html
index 4197b61..f31aea0 100644
--- a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/var/mod.rs.html
+++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/var/mod.rs.html
@@ -21,12 +21,15 @@
 21
 22
 23
+24
+25
 
 mod get_all_var_names;
 mod get_by_name;
 pub(crate) mod set;
 mod set_by_name;
 mod unset;
+mod unset_all_vars;
 
 use crate::utils::pckg;
 use duckscript::types::command::Commands;
@@ -42,6 +45,7 @@
     commands.set(set::create(&package))?;
     commands.set(set_by_name::create(&package))?;
     commands.set(unset::create(&package)?)?;
+    commands.set(unset_all_vars::create(&package))?;
 
     Ok(())
 }
diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/var/unset_all_vars/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/var/unset_all_vars/mod.rs.html
new file mode 100644
index 0000000..d5b5ede
--- /dev/null
+++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/var/unset_all_vars/mod.rs.html
@@ -0,0 +1,129 @@
+mod.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+
+use crate::utils::pckg;
+use duckscript::types::command::{Command, CommandResult, Commands};
+use duckscript::types::instruction::Instruction;
+use duckscript::types::runtime::StateValue;
+use std::collections::HashMap;
+
+#[cfg(test)]
+#[path = "./mod_test.rs"]
+mod mod_test;
+
+#[derive(Clone)]
+pub(crate) struct CommandImpl {
+    package: String,
+}
+
+impl Command for CommandImpl {
+    fn name(&self) -> String {
+        pckg::concat(&self.package, "UnsetAllVars")
+    }
+
+    fn aliases(&self) -> Vec<String> {
+        vec!["unset_all_vars".to_string()]
+    }
+
+    fn help(&self) -> String {
+        include_str!("help.md").to_string()
+    }
+
+    fn clone_and_box(&self) -> Box<dyn Command> {
+        Box::new((*self).clone())
+    }
+
+    fn requires_context(&self) -> bool {
+        true
+    }
+
+    fn run_with_context(
+        &self,
+        arguments: Vec<String>,
+        _state: &mut HashMap<String, StateValue>,
+        variables: &mut HashMap<String, String>,
+        _output_variable: Option<String>,
+        _instructions: &Vec<Instruction>,
+        _commands: &mut Commands,
+        _line: usize,
+    ) -> CommandResult {
+        if arguments.len() > 1 && arguments[0] == "--prefix" {
+            let prefix = &arguments[1];
+
+            variables.retain(|key, _| !key.starts_with(prefix));
+        } else {
+            variables.clear();
+        }
+
+        CommandResult::Continue(None)
+    }
+}
+
+pub(crate) fn create(package: &str) -> Box<dyn Command> {
+    Box::new(CommandImpl {
+        package: package.to_string(),
+    })
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/types/command.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/types/command.rs.html index 750e70d..158608d 100644 --- a/docs/api/duckscript_sdk/src/duckscriptsdk/types/command.rs.html +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/types/command.rs.html @@ -175,6 +175,37 @@ 175 176 177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208
 use crate::types::scope::clear;
 use crate::types::scope::set_line_context_name;
@@ -332,6 +363,30 @@
     }
 }
 
+#[derive(Clone)]
+struct DocOnlyCommand {
+    name: String,
+    help: String,
+}
+
+impl Command for DocOnlyCommand {
+    fn name(&self) -> String {
+        self.name.clone()
+    }
+
+    fn help(&self) -> String {
+        self.help.clone()
+    }
+
+    fn clone_and_box(&self) -> Box<dyn Command> {
+        Box::new((*self).clone())
+    }
+
+    fn run(&self, _arguments: Vec<String>) -> CommandResult {
+        CommandResult::Error("Documentation only commands should not be executed.".to_string())
+    }
+}
+
 pub(crate) fn create_alias_command(
     name: String,
     aliases: Vec<String>,
@@ -353,5 +408,12 @@
 
     Ok(command)
 }
+
+pub(crate) fn create_doc_only_command(name: &str, help: &str) -> Box<dyn Command> {
+    Box::new(DocOnlyCommand {
+        name: name.to_string(),
+        help: help.to_string(),
+    })
+}
 
\ No newline at end of file diff --git a/duckscript_cli/Cargo.toml b/duckscript_cli/Cargo.toml index 8df5fe0..a9111da 100644 --- a/duckscript_cli/Cargo.toml +++ b/duckscript_cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "duckscript_cli" -version = "0.6.3" +version = "0.6.4" authors = ["Sagie Gur-Ari "] description = "The duckscript command line executable." license = "Apache-2.0" @@ -28,7 +28,7 @@ path = "src/main.rs" [dependencies] duckscript = { version = "^0.5.0", path = "../duckscript" } -duckscriptsdk = { version = "^0.6.3", path = "../duckscript_sdk" } +duckscriptsdk = { version = "^0.6.4", path = "../duckscript_sdk" } [badges.codecov] branch = "master" diff --git a/duckscript_sdk/Cargo.toml b/duckscript_sdk/Cargo.toml index 3f56a22..e178645 100644 --- a/duckscript_sdk/Cargo.toml +++ b/duckscript_sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "duckscriptsdk" -version = "0.6.3" +version = "0.6.4" authors = ["Sagie Gur-Ari "] description = "The duckscript SDK." license = "Apache-2.0"