Skip to content

Commit

Permalink
Update for Nu 0.95 (#21)
Browse files Browse the repository at this point in the history
New metadata call with version field

Fixes #20
  • Loading branch information
tesujimath authored Jun 27, 2024
1 parent 4f01ed9 commit 11ebdf6
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: test suite
on: [push, pull_request]
env:
NU_VERSION: 0.94.1
NU_VERSION: 0.95.0

jobs:
test:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ The following versions are compatible.
| 0.93 | 0.8.0 |
| 0.93 | 0.9.0 |
| 0.94 | 0.10.0 |
| 0.95 | 0.11.0 |

If you find a new version of Nushell rejects this plugin as incompatible, please report an [issue](https://github.com/tesujimath/nu_plugin_bash_env/issues).

Expand Down
76 changes: 53 additions & 23 deletions api/Cargo.lock

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

6 changes: 3 additions & 3 deletions api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nu_plugin_bash_env_api"
version = "0.10.0"
version = "0.11.0"
edition = "2021"
license = "MIT"
description = "API for Nu plugin bash-env"
Expand All @@ -9,5 +9,5 @@ repository = "https://github.com/tesujimath/nu_plugin_bash_env"
readme = "README.md"

[dependencies]
nu-plugin = "0.94.1"
nu-protocol = "0.94.1"
nu-plugin = "0.95.0"
nu-protocol = "0.95.0"
4 changes: 4 additions & 0 deletions api/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ impl Plugin for BashEnvApiPlugin {
fn commands(&self) -> Vec<Box<dyn PluginCommand<Plugin = Self>>> {
vec![Box::new(BashEnvApi)]
}

fn version(&self) -> String {
env!("CARGO_PKG_VERSION").to_string()
}
}

struct BashEnvApi;
Expand Down
22 changes: 21 additions & 1 deletion nu_plugin_bash_env
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

PROTOCOL_VERSION="0.94.1"
VERSION="0.11.0"
PROTOCOL_VERSION="0.95.0"

shopt -s extglob

Expand All @@ -42,6 +43,22 @@ function send_hello() {
EOF
}

function send_metadata() {
_call_id="$1"
jq -c <<EOF
{
"CallResponse": [
$_call_id,
{
"Metadata": {
"version": "$VERSION"
}
}
]
}
EOF
}

function send_signature() {
_call_id="$1"
jq -c <<EOF
Expand Down Expand Up @@ -343,6 +360,9 @@ function run_as_plugin() {
\{\"Call\":\[+([0-9]),*)
_call_id=$(jq '.Call[0]' <<<"$_line")
case "$_line" in
\{\"Call\":\[+([0-9]),\"Metadata\"*)
send_metadata "$_call_id"
;;
\{\"Call\":\[+([0-9]),\"Signature\"*)
send_signature "$_call_id"
;;
Expand Down

0 comments on commit 11ebdf6

Please sign in to comment.