Skip to content

Commit

Permalink
release
Browse files Browse the repository at this point in the history
  • Loading branch information
sagiegurari committed Oct 4, 2024
1 parent 5299842 commit 810da9d
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .buildnumber
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12
13
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## CHANGELOG

### v0.11.0
### v0.11.0 (2024-10-04)

* Enhancement: Runtime - \[Breaking Change\] Renamed command args to context.

Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ Commands are structs that must implement the Command trait.<br>
* They should return help documentation in markdown format in order to generate SDK documentation (must for PRs to duckscript official SDK).<br>
* They must implement the **run** function which holds the command logic.<br>
The run function accepts the command arguments (args array contains actual values and not original variables) and returns the command result.<br>
The run function accepts the command invocation context (args array contains actual values and not original variables) and returns the command result.<br>
The command result can be one of the following:
* Continue(Option<String>) - Tells the runner to continue to the next command and optionally set the output variable the given value.
Expand All @@ -437,11 +437,11 @@ impl Command for SetCommand {
Box::new((*self).clone())
}
fn run(&self, arguments: CommandArgs) -> CommandResult {
let output = if arguments.args.is_empty() {
fn run(&self, context: CommandInvocationContext) -> CommandResult {
let output = if context.arguments.is_empty() {
None
} else {
Some(arguments.args[0].clone())
Some(context.arguments[0].clone())
};
CommandResult::Continue(output)
Expand All @@ -468,11 +468,11 @@ impl Command for GetEnvCommand {
Box::new((*self).clone())
}
fn run(&self, arguments: CommandArgs) -> CommandResult {
if arguments.args.is_empty() {
fn run(&self, context: CommandInvocationContext) -> CommandResult {
if context.arguments.is_empty() {
CommandResult::Error("Missing environment variable name.".to_string())
} else {
match env::var(&arguments.args[0]) {
match env::var(&context.arguments[0]) {
Ok(value) => CommandResult::Continue(Some(value)),
Err(_) => CommandResult::Continue(None),
}
Expand All @@ -485,21 +485,21 @@ You can look at more examples in the duckscript_sdk folder.
<a name="sdk-tutorial-commands-context"></a>
## Access The Context
The duckscript runtime context is available in the CommandArgs struc.<br>
The duckscript runtime context is available in the CommandInvocationContext struc.<br>
```rust
/// Run the instruction with access to the runtime context.
///
/// The CommandArgs has the following members:
/// * `args` - The command arguments array
/// The CommandInvocationContext has the following members:
/// * `arguments` - The command arguments array
/// * `state` - Internal state which is only used by commands to store/pull data
/// * `variables` - All script variables
/// * `output_variable` - The output variable name (if defined)
/// * `instructions` - The entire list of instructions which make up the currently running script
/// * `commands` - The currently known commands
/// * `line` - The current instruction line number (global line number after including all scripts into one global script)
/// * `env` - The current runtime env with access to out/err writers, etc...
fn run(&self, arguments: CommandArgs) -> CommandResult;
fn run(&self, context: CommandInvocationContext) -> CommandResult;
```
With access to this context you can add/remove/switch commands in runtime, store/pull internal state, add/remove/change variables and so on...
Expand Down
22 changes: 11 additions & 11 deletions docs/_includes/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ Commands are structs that must implement the Command trait.<br>
* They should return help documentation in markdown format in order to generate SDK documentation (must for PRs to duckscript official SDK).<br>
* They must implement the **run** function which holds the command logic.<br>
The run function accepts the command arguments (args array contains actual values and not original variables) and returns the command result.<br>
The run function accepts the command invocation context (args array contains actual values and not original variables) and returns the command result.<br>
The command result can be one of the following:
* Continue(Option<String>) - Tells the runner to continue to the next command and optionally set the output variable the given value.
Expand All @@ -392,11 +392,11 @@ impl Command for SetCommand {
Box::new((*self).clone())
}
fn run(&self, arguments: CommandArgs) -> CommandResult {
let output = if arguments.args.is_empty() {
fn run(&self, context: CommandInvocationContext) -> CommandResult {
let output = if context.arguments.is_empty() {
None
} else {
Some(arguments.args[0].clone())
Some(context.arguments[0].clone())
};
CommandResult::Continue(output)
Expand All @@ -423,11 +423,11 @@ impl Command for GetEnvCommand {
Box::new((*self).clone())
}
fn run(&self, arguments: CommandArgs) -> CommandResult {
if arguments.args.is_empty() {
fn run(&self, context: CommandInvocationContext) -> CommandResult {
if context.arguments.is_empty() {
CommandResult::Error("Missing environment variable name.".to_string())
} else {
match env::var(&arguments.args[0]) {
match env::var(&context.arguments[0]) {
Ok(value) => CommandResult::Continue(Some(value)),
Err(_) => CommandResult::Continue(None),
}
Expand All @@ -440,21 +440,21 @@ You can look at more examples in the duckscript_sdk folder.
<a name="sdk-tutorial-commands-context"></a>
## Access The Context
The duckscript runtime context is available in the CommandArgs struc.<br>
The duckscript runtime context is available in the CommandInvocationContext struc.<br>
```rust
/// Run the instruction with access to the runtime context.
///
/// The CommandArgs has the following members:
/// * `args` - The command arguments array
/// The CommandInvocationContext has the following members:
/// * `arguments` - The command arguments array
/// * `state` - Internal state which is only used by commands to store/pull data
/// * `variables` - All script variables
/// * `output_variable` - The output variable name (if defined)
/// * `instructions` - The entire list of instructions which make up the currently running script
/// * `commands` - The currently known commands
/// * `line` - The current instruction line number (global line number after including all scripts into one global script)
/// * `env` - The current runtime env with access to out/err writers, etc...
fn run(&self, arguments: CommandArgs) -> CommandResult;
fn run(&self, context: CommandInvocationContext) -> CommandResult;
```
With access to this context you can add/remove/switch commands in runtime, store/pull internal state, add/remove/change variables and so on...
Expand Down
2 changes: 1 addition & 1 deletion duckscript/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "duckscript"
version = "0.9.0"
version = "0.10.0"
authors = ["Sagie Gur-Ari <[email protected]>"]
description = "Simple, extendable and embeddable scripting language."
license = "Apache-2.0"
Expand Down
6 changes: 3 additions & 3 deletions duckscript_cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "duckscript_cli"
version = "0.10.0"
version = "0.11.0"
authors = ["Sagie Gur-Ari <[email protected]>"]
description = "The duckscript command line executable."
license = "Apache-2.0"
Expand All @@ -27,8 +27,8 @@ name = "duck"
path = "src/main.rs"

[dependencies]
duckscript = { version = "^0.9.0", path = "../duckscript" }
duckscriptsdk = { version = "^0.10.0", path = "../duckscript_sdk", default-features = false }
duckscript = { version = "^0.10.0", path = "../duckscript" }
duckscriptsdk = { version = "^0.11.0", path = "../duckscript_sdk", default-features = false }

[features]
tls-rustls = ["duckscriptsdk/tls-rustls"]
Expand Down
4 changes: 2 additions & 2 deletions duckscript_sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "duckscriptsdk"
version = "0.10.0"
version = "0.11.0"
authors = ["Sagie Gur-Ari <[email protected]>"]
description = "The duckscript SDK."
license = "Apache-2.0"
Expand Down Expand Up @@ -29,7 +29,7 @@ attohttpc = { version = "^0.28", default-features = false, features = [
base64 = "^0.22"
cfg-if = "^1"
colored = "^2"
duckscript = { version = "^0.9.0", path = "../duckscript" }
duckscript = { version = "^0.10.0", path = "../duckscript" }
evalexpr = "^11"
fs_extra = "^1"
fsio = { version = "^0.4", features = ["temp-path"] }
Expand Down

0 comments on commit 810da9d

Please sign in to comment.