diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index ae485bf..2e778dc 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -7,8 +7,8 @@ on: branches: - main env: - NU_VERSION: 0.106.0 - BASH_ENV_JSON_VERSION: 0.10.1 + NU_VERSION: 0.116.1 + BASH_ENV_JSON_VERSION: 0.11.0 jobs: test: @@ -19,7 +19,7 @@ jobs: uses: actions/checkout@v4 - name: Download Nushell $NU_VERSION run: | - curl -L https://github.com/nushell/nushell/releases/download/${NU_VERSION}/nu-${NU_VERSION}-x86_64-unknown-linux-gnu.tar.gz | tar xzf - + curl -L "https://github.com/nushell/nushell/releases/download/${NU_VERSION}/nu-${NU_VERSION}-x86_64-unknown-linux-gnu.tar.gz" | tar xzf - - name: Version Check run: | export PATH=./nu-${NU_VERSION}-x86_64-unknown-linux-gnu:$PATH @@ -28,11 +28,12 @@ jobs: jq --version - name: Download bash-env-json $BASH_ENV_JSON_VERSION run: | - curl -L https://github.com/tesujimath/bash-env-json/archive/refs/tags/${BASH_ENV_JSON_VERSION}.tar.gz | tar xzf - + curl -L "https://github.com/tesujimath/bash-env-json/archive/refs/tags/${BASH_ENV_JSON_VERSION}.tar.gz" | tar xzf - - name: Run Module Tests run: | # note that Nushell doesn't like relative paths on the $PATH - export PATH=$(pwd)/bash-env-json-${BASH_ENV_JSON_VERSION}:./nu-${NU_VERSION}-x86_64-unknown-linux-gnu:$PATH + PATH="$(pwd)/bash-env-json-${BASH_ENV_JSON_VERSION}:./nu-${NU_VERSION}-x86_64-unknown-linux-gnu:$PATH" + export PATH which bash-env-json nu --no-config-file --no-history -c "use bash-env.nu ; use tests.nu run_bash_env_tests ; run_bash_env_tests" nu --no-config-file --no-history -c "use bash-env.nu ; use extra-module-tests.nu ; extra-module-tests" diff --git a/README.md b/README.md index f817d3e..a2a7c1f 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,19 @@ b Rather than folding shell variables in with the environment variables as was done by the plugin, the `-s` or `--shellvars` option results in structured output with separate `env` and `shellvars`. +The `--export` option is deprecated. It returns a flat record containing environment changes merged with selected shell variables. To retrieve selected shell variables with `--shellvars`, select them from the nested `shellvars` record: + +```nu +(bash-env ./environment.sh --shellvars).shellvars | select A +``` + +If you also need the environment changes returned by `--export [A]`, merge the records: + +```nu +let changes = bash-env ./environment.sh --shellvars +$changes.env | merge ($changes.shellvars | select --optional A) +``` + ``` > echo "ABC=123" | bash-env ╭──────────────╮ diff --git a/extra-module-tests.nu b/extra-module-tests.nu index fd24d28..e81f942 100644 --- a/extra-module-tests.nu +++ b/extra-module-tests.nu @@ -1,4 +1,4 @@ -use std assert +use std/assert # TODO use testing.nu testing module, # which wasn't working at the time I wrote these tests diff --git a/flake.lock b/flake.lock index 9cf191e..2e870ce 100644 --- a/flake.lock +++ b/flake.lock @@ -2,17 +2,16 @@ "nodes": { "bash-env-json": { "inputs": { - "flake-utils": "flake-utils", "nixpkgs": [ "nixpkgs" ] }, "locked": { - "lastModified": 1735682486, - "narHash": "sha256-IHfUIAkpaRyBmzT654bAzpTHUhcrtU643uxkPbveYOM=", + "lastModified": 1786572290, + "narHash": "sha256-5wi9DxK2Up+lM3EY9YRyNRfkwmzqVbHPLAr0fOboWWo=", "owner": "tesujimath", "repo": "bash-env-json", - "rev": "36bb756f38282e33deeed8e27618ecde3503e032", + "rev": "54605ef06cab813c80e7d78262a1aac46949a21b", "type": "github" }, "original": { @@ -26,24 +25,6 @@ "inputs": { "systems": "systems" }, - "locked": { - "lastModified": 1726560853, - "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_2": { - "inputs": { - "systems": "systems_2" - }, "locked": { "lastModified": 1710146030, "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", @@ -60,11 +41,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1739138025, - "narHash": "sha256-M4ilIfGxzbBZuURokv24aqJTbdjPA9K+DtKUzrJaES4=", + "lastModified": 1791966044, + "narHash": "sha256-t1hT8UW97rFCWCJO7/pClvu0AhLN5V3uir2M0ic4w/Q=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b2243f41e860ac85c0b446eadc6930359b294e79", + "rev": "319e4cebef10cbb636c6ea392137b52ad105336a", "type": "github" }, "original": { @@ -77,7 +58,7 @@ "root": { "inputs": { "bash-env-json": "bash-env-json", - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } }, @@ -95,21 +76,6 @@ "repo": "default", "type": "github" } - }, - "systems_2": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/tests.nu b/tests.nu index bfebb77..b2f3cd0 100644 --- a/tests.nu +++ b/tests.nu @@ -1,4 +1,4 @@ -use std assert +use std/assert # TODO use testing.nu testing module, # which wasn't working at the time I wrote these tests