Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Elvish Shell support #1066

Merged
merged 34 commits into from Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1af3e99
feat: Elvish Shell support
elijahr Oct 8, 2021
e8e631c
Fix asdf.elv, add install docs
elijahr Oct 9, 2021
6e8cf29
Update docs and tests
elijahr Oct 9, 2021
242b88d
fix shellcheck issues
elijahr Oct 9, 2021
6baada0
Fix tests
elijahr Oct 9, 2021
2b034c9
Fix test
elijahr Oct 9, 2021
5bb00bb
Fix other test
elijahr Oct 9, 2021
1f1f570
Fix tests on older elvish
elijahr Oct 9, 2021
dfdb59c
Fix test
elijahr Oct 9, 2021
8f7ea81
Install newer elvish
elijahr Oct 9, 2021
b05968f
Fix test
elijahr Oct 9, 2021
8c7fb68
Add test for running command
elijahr Oct 9, 2021
7cabf9b
Add test for running asdf subcommands
elijahr Oct 9, 2021
1a15a53
Linter
elijahr Oct 9, 2021
5186c1a
Remove command keyword
elijahr Oct 9, 2021
cec89d7
Fix test
elijahr Oct 9, 2021
6b49ba2
Fix test
elijahr Oct 9, 2021
207f1c1
-norc
elijahr Oct 9, 2021
384f450
Add completions
elijahr Oct 9, 2021
02069ff
Fix test
elijahr Oct 9, 2021
9ba6749
Single module for asdf function & completions
elijahr Oct 9, 2021
1295224
Fix uninstall instructions
elijahr Oct 9, 2021
84f073a
Cleanup debug code
elijahr Oct 9, 2021
2c9529b
Comments
elijahr Oct 9, 2021
f871425
Fix completer in unit tests
elijahr Oct 9, 2021
fa84123
Add unit test for ASDF_DATA_DIR
elijahr Oct 9, 2021
9036d91
Revert change in command-info.bash
elijahr Oct 9, 2021
ab495ff
Fix installation instructions
elijahr Oct 9, 2021
0b006ed
Add flags
elijahr Oct 10, 2021
4383fbe
Ignore downloads dir
elijahr Oct 10, 2021
624949c
Use regex for matching
elijahr Oct 10, 2021
0b41485
Add plugin-test completion
elijahr Oct 10, 2021
e697aab
Format string
elijahr Nov 13, 2021
2538279
Download elvish binary
elijahr Nov 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 34 additions & 0 deletions lib/asdf.elv
@@ -0,0 +1,34 @@
use path

asdf_dir = (path:dir (src)[name])
put $asdf_dir
set-env ASDF_DIR $asdf_dir

var asdf_user_shims
if (and (has-env "ASDF_DATA_DIR") (not (== $E:ASDF_DATA_DIR ""))) {
asdf_user_shims = $E:ASDF_DATA_DIR/shims
} else {
asdf_user_shims = $asdf_dir/shims
}

# Add asdf to PATH
for path [
$asdf_dir/bin
$asdf_user_shims
] {
if (not (has-value $paths $path)) {
paths = [$path $@paths]
put $paths
}
}

# Add function wrapper so we can export variables
fn asdf [command @args]{
if (== $command "shell") {
# source commands that need to export variables
eval (slurp <(asdf export-shell-version elvish $@args))
elijahr marked this conversation as resolved.
Show resolved Hide resolved
} else {
# forward other commands to asdf script
command asdf $command $@args
}
}
6 changes: 6 additions & 0 deletions lib/commands/command-export-shell-version.bash
Expand Up @@ -23,6 +23,9 @@ shell_command() {
fish)
printf "set -e %s\\n" "$version_env_var"
;;
elvish)
echo "unset-env $version_env_var"
;;
*)
printf "unset %s\\n" "$version_env_var"
;;
Expand All @@ -42,6 +45,9 @@ shell_command() {
fish)
printf "set -gx %s \"%s\"\\n" "$version_env_var" "$version"
;;
elvish)
echo "set-env $version_env_var \"$version\""
;;
*)
printf "export %s=\"%s\"\\n" "$version_env_var" "$version"
;;
Expand Down
12 changes: 12 additions & 0 deletions test/version_commands.bats
Expand Up @@ -371,6 +371,12 @@ false"
[ "$output" = "set -gx ASDF_DUMMY_VERSION \"1.1.0\"" ]
}

@test "export-shell-version should use set-env when shell is elvish" {
run asdf export-shell-version elvish "dummy" "1.1.0"
[ "$status" -eq 0 ]
[ "$output" = "set-env ASDF_DUMMY_VERSION \"1.1.0\"" ]
}

@test "export-shell-version should unset when --unset flag is passed" {
run asdf export-shell-version sh "dummy" "--unset"
[ "$status" -eq 0 ]
Expand All @@ -383,6 +389,12 @@ false"
[ "$output" = "set -e ASDF_DUMMY_VERSION" ]
}

@test "export-shell-version should use unset-env when --unset flag is passed and shell is elvish" {
run asdf export-shell-version elvish "dummy" "--unset"
[ "$status" -eq 0 ]
[ "$output" = "unset-env ASDF_DUMMY_VERSION" ]
}

@test "[shell - dummy_plugin] wrapper function should support latest" {
. $(dirname "$BATS_TEST_DIRNAME")/asdf.sh
asdf shell "dummy" "latest"
Expand Down