From 1af3e99c63c5b0dc2b493417526de847f1d91361 Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Thu, 7 Oct 2021 22:41:51 -0500 Subject: [PATCH 01/34] feat: Elvish Shell support --- lib/asdf.elv | 34 +++++++++++++++++++ .../command-export-shell-version.bash | 6 ++++ test/version_commands.bats | 12 +++++++ 3 files changed, 52 insertions(+) create mode 100644 lib/asdf.elv diff --git a/lib/asdf.elv b/lib/asdf.elv new file mode 100644 index 000000000..05b230fa7 --- /dev/null +++ b/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)) + } else { + # forward other commands to asdf script + command asdf $command $@args + } +} diff --git a/lib/commands/command-export-shell-version.bash b/lib/commands/command-export-shell-version.bash index 6e3fa371d..8524b5a05 100644 --- a/lib/commands/command-export-shell-version.bash +++ b/lib/commands/command-export-shell-version.bash @@ -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" ;; @@ -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" ;; diff --git a/test/version_commands.bats b/test/version_commands.bats index 35fcb7a3a..8d36425af 100644 --- a/test/version_commands.bats +++ b/test/version_commands.bats @@ -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 ] @@ -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" From e8e631c4548b3bf41c81edf64a53d8671e3ca0f0 Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Fri, 8 Oct 2021 23:13:30 -0500 Subject: [PATCH 02/34] Fix asdf.elv, add install docs --- asdf.elv | 28 +++++++++++++++ docs/guide/getting-started.md | 36 +++++++++++++++++++ lib/asdf.elv | 34 ------------------ .../command-export-shell-version.bash | 5 ++- 4 files changed, 68 insertions(+), 35 deletions(-) create mode 100644 asdf.elv delete mode 100644 lib/asdf.elv diff --git a/asdf.elv b/asdf.elv new file mode 100644 index 000000000..3000bf5a1 --- /dev/null +++ b/asdf.elv @@ -0,0 +1,28 @@ +use path + +asdf_dir = (path:eval-symlinks (path:dir (path:eval-symlinks (src)[name]))"/..") +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 shims to PATH +if (not (has-value $paths $asdf_user_shims)) { + paths = [$@paths $asdf_user_shims] +} + +# Add function wrapper so we can export variables +fn asdf [command @args]{ + if (==s $command "shell") { + # set environment variables + parts = [($asdf_dir"/bin/asdf" export-shell-version elvish $@args)] + set-env $parts[0] $parts[1] + } else { + # forward other commands to asdf script + command $asdf_dir"/bin/asdf" $command $@args + } +} diff --git a/docs/guide/getting-started.md b/docs/guide/getting-started.md index 171e32a38..ef761f925 100644 --- a/docs/guide/getting-started.md +++ b/docs/guide/getting-started.md @@ -142,6 +142,42 @@ source /opt/asdf-vm/asdf.fish Completions are automatically configured on installation by the AUR package. ::: +::: details Elvish & Git + +Add `asdf.elv` to your `~/.elvish/rc.elv` with: + +```shell:no-line-numbers +mkdir -p ~/.elvish/lib +ln -s ~/.asdf/asdf.elv ~/.elvish/lib/asdf.elv +echo "\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}" >> ~/.elvish/rc.elv +``` + +::: + +::: details Elvish & Homebrew + +Add `asdf.elv` to your `~/.elvish/rc.elv` with: + +```shell:no-line-numbers +mkdir -p ~/.elvish/lib +ln -s (brew --prefix asdf)/libexec/asdf.elv ~/.elvish/lib/asdf.elv +echo "\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}" >> ~/.elvish/rc.elv +``` + +::: + +::: details Elvish & Pacman + +Add `asdf.elv` to your `~/.elvish/rc.elv` with: + +```shell:no-line-numbers +mkdir -p ~/.elvish/lib +ln -s /opt/asdf-vm/asdf.elv ~/.elvish/lib/asdf.elv +echo "\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}" >> ~/.elvish/rc.elv +``` + +::: + ::: details ZSH & Git Add the following to `~/.zshrc`: diff --git a/lib/asdf.elv b/lib/asdf.elv deleted file mode 100644 index 05b230fa7..000000000 --- a/lib/asdf.elv +++ /dev/null @@ -1,34 +0,0 @@ -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)) - } else { - # forward other commands to asdf script - command asdf $command $@args - } -} diff --git a/lib/commands/command-export-shell-version.bash b/lib/commands/command-export-shell-version.bash index 8524b5a05..20a5ec341 100644 --- a/lib/commands/command-export-shell-version.bash +++ b/lib/commands/command-export-shell-version.bash @@ -46,7 +46,10 @@ shell_command() { printf "set -gx %s \"%s\"\\n" "$version_env_var" "$version" ;; elvish) - echo "set-env $version_env_var \"$version\"" + # Elvish doesn't have a `source` command, and eval is banned, so the + # var name and value are printed on separate lines for asdf.elv to parse + # and pass to set-env. + printf "$version_env_var\n$version" ;; *) printf "export %s=\"%s\"\\n" "$version_env_var" "$version" From 6e8cf29538057e25859273effeb927a589815574 Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 01:11:17 -0500 Subject: [PATCH 03/34] Update docs and tests --- .gitattributes | 1 + .github/workflows/tests.yml | 4 +- README.md | 2 +- asdf.elv | 8 +- docs/index.md | 2 +- docs/manage/configuration.md | 2 +- docs/manage/core.md | 90 +++++++++++++++++++ docs/manage/versions.md | 2 +- docs/pt-br/index.md | 2 +- docs/pt-br/learn-more/faq.md | 28 +++--- docs/pt-br/manage/configuration.md | 2 +- docs/pt-br/manage/core.md | 90 +++++++++++++++++++ docs/pt-br/manage/versions.md | 2 +- .../command-export-shell-version.bash | 7 +- test/asdf_elvish.bats | 63 +++++++++++++ test/banned_commands.bats | 2 +- test/version_commands.bats | 4 +- 17 files changed, 280 insertions(+), 31 deletions(-) create mode 100644 test/asdf_elvish.bats diff --git a/.gitattributes b/.gitattributes index 2e8be48fe..5729e7a20 100644 --- a/.gitattributes +++ b/.gitattributes @@ -22,6 +22,7 @@ *.sh text *.bash text *.fish text +*.elv text #### asdf/bin/* explicitly define as text *asdf text *asdf-exec text diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 87da6afcb..77aeda7df 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,7 +28,7 @@ jobs: - name: Install test dependencies if: runner.os == 'macos' - run: brew install coreutils fish + run: brew install coreutils fish elvish - name: Install test dependencies if: runner.os == 'linux' @@ -36,7 +36,7 @@ jobs: PPA="ppa:fish-shell/nightly-master" sudo add-apt-repository -y "$PPA" sudo apt-get update - sudo apt-get -y install fish + sudo apt-get -y install fish elvish - name: Install bats run: | diff --git a/README.md b/README.md index 6c0d21b87..f9f4120ed 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ asdf is a CLI tool that can manage multiple language runtime versions on a per-p - support for existing config files `.node-version`, `.nvmrc`, `.ruby-version` for easy migration - automatically switches runtime versions as you traverse your directories - simple plugin system to add support for your language of choice -- shell completion available for common shells (Bash, Zsh, Fish) +- shell completion available for common shells (Bash, Zsh, Fish, Elvish) ## Documentation diff --git a/asdf.elv b/asdf.elv index 3000bf5a1..7261a7889 100644 --- a/asdf.elv +++ b/asdf.elv @@ -1,6 +1,6 @@ use path -asdf_dir = (path:eval-symlinks (path:dir (path:eval-symlinks (src)[name]))"/..") +asdf_dir = (path:eval-symlinks (path:dir (path:eval-symlinks (src)[name]))) set-env ASDF_DIR $asdf_dir var asdf_user_shims @@ -20,7 +20,11 @@ fn asdf [command @args]{ if (==s $command "shell") { # set environment variables parts = [($asdf_dir"/bin/asdf" export-shell-version elvish $@args)] - set-env $parts[0] $parts[1] + if (==s $parts[0] "set-env") { + set-env $parts[1] $parts[2] + } elif (==s $parts[0] "unset-env") { + unset-env $parts[1] + } } else { # forward other commands to asdf script command $asdf_dir"/bin/asdf" $command $@args diff --git a/docs/index.md b/docs/index.md index 46e8a8a1c..1ef60a1b3 100644 --- a/docs/index.md +++ b/docs/index.md @@ -19,7 +19,7 @@ features: - title: "One Config File" details: ".tool-versions to manage all your tools, runtimes and their versions in a single, sharable place." - title: "Shells" - details: "Supports Bash, ZSH & Fish with completions available." + details: "Supports Bash, ZSH, Fish & Elvish with completions available." - title: "GitHub Actions" details: "Provides a GitHub Action to install and utilize your .tool-versions in your CI/CD workflows." # footer: MIT Licensed diff --git a/docs/manage/configuration.md b/docs/manage/configuration.md index dfe774c01..1b240e67d 100644 --- a/docs/manage/configuration.md +++ b/docs/manage/configuration.md @@ -93,7 +93,7 @@ Configure the duration since the last asdf plugin repository sync to the next. C - `ASDF_CONFIG_FILE` - Defaults to `~/.asdfrc` as described above. Can be set to any location. - `ASDF_DEFAULT_TOOL_VERSIONS_FILENAME` - The filename of the file storing the tool names and versions. Defaults to `.tool-versions`. Can be any valid filename. Typically you should not override the default value unless you know you want asdf to ignore `.tool-versions` files. - `ASDF_DIR` - Defaults to `~/.asdf` - Location of the `asdf` scripts. If you install `asdf` to some other directory, set this to that directory. For example, if you are installing via the AUR, you should set this to `/opt/asdf-vm`. -- `ASDF_DATA_DIR` - Defaults to `~/.asdf` - Location where `asdf` install plugins, shims and installs. Can be set to any location before sourcing `asdf.sh` or `asdf.fish` mentioned in the section above. +- `ASDF_DATA_DIR` - Defaults to `~/.asdf` - Location where `asdf` install plugins, shims and installs. Can be set to any location before sourcing `asdf.sh` or `asdf.fish` mentioned in the section above. For Elvish, this can be set above `use asdf`. ## Internal Configuration diff --git a/docs/manage/core.md b/docs/manage/core.md index 37460875c..c8c06e6fa 100644 --- a/docs/manage/core.md +++ b/docs/manage/core.md @@ -257,6 +257,96 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc ::: +::: details Elvish & Git + +1. In your `~/.elvish/rc.elv` remove the line that imports the `asdf` module: + +```shell +use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} +``` + +and uninstall the `asdf` module with this command: + +```shell:no-line-numbers +rm -rf ~/.elvish/lib/asdf.elv +``` + +2. Remove the `$HOME/.asdf` dir: + +```shell:no-line-numbers +if (!=s $E:ASDF_DATA_DIR "") { rm -rf $ASDF_DATA_DIR"/.asdf" } else { rm -rf ~/.asdf } +``` + +3. Run this command to remove all `asdf` config files: + +```shell:no-line-numbers +rm -rf $HOME/.tool-versions $HOME/.asdfrc +``` + +::: + +::: details Elvish & Homebrew + +1. In your `~/.elvish/rc.elv` remove the line that imports the `asdf` module: + +```shell +use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} +``` + +and uninstall the `asdf` module with this command: + +```shell:no-line-numbers +rm -rf ~/.elvish/lib/asdf.elv +``` + +2. Uninstall with your package manager: + +```shell:no-line-numbers +brew uninstall asdf --force +``` + +3. Run this command to remove all `asdf` config files: + +```shell:no-line-numbers +rm -rf $HOME/.tool-versions $HOME/.asdfrc +``` + +::: + +::: details Elvish & Pacman + +1. In your `~/.elvish/rc.elv` remove the line that imports the `asdf` module: + +```shell +use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} +``` + +and uninstall the `asdf` module with this command: + +```shell:no-line-numbers +rm -rf ~/.elvish/lib/asdf.elv +``` + +2. Uninstall with your package manager: + +```shell:no-line-numbers +pacman -Rs asdf-vm +``` + +3. Remove the `$HOME/.asdf` dir: + +```shell:no-line-numbers +if (!=s $E:ASDF_DATA_DIR "") { rm -rf $ASDF_DATA_DIR"/.asdf" } else { rm -rf ~/.asdf } +``` + +4. Run this command to remove all `asdf` config files: + +```shell:no-line-numbers +rm -rf $HOME/.tool-versions $HOME/.asdfrc +``` + +::: + ::: details ZSH & Git 1. In your `~/.zshrc` remove the lines that source `asdf.sh` and completions: diff --git a/docs/manage/versions.md b/docs/manage/versions.md index 0f008f546..55690de62 100644 --- a/docs/manage/versions.md +++ b/docs/manage/versions.md @@ -132,7 +132,7 @@ asdf uninstall ## Shims -When asdf installs a package it creates shims for every executable program in that package in a `$ASDF_DATA_DIR/shims` directory (default `~/.asdf/shims`). This directory being on the `$PATH` (by means of `asdf.sh` or `asdf.fish`) is how the installed programs are made available in the environment. +When asdf installs a package it creates shims for every executable program in that package in a `$ASDF_DATA_DIR/shims` directory (default `~/.asdf/shims`). This directory being on the `$PATH` (by means of `asdf.sh`, `asdf.fish`, etc) is how the installed programs are made available in the environment. The shims themselves are really simple wrappers that `exec` a helper program `asdf exec` passing it the name of the plugin and path to the executable in the installed package that the shim is wrapping. diff --git a/docs/pt-br/index.md b/docs/pt-br/index.md index 667269902..174362685 100644 --- a/docs/pt-br/index.md +++ b/docs/pt-br/index.md @@ -19,7 +19,7 @@ features: - title: "Só um arquivo de configuração" details: ".tool-versions para gerenciar todas as suas ferramentas, runtimes e suas versões em um único arquivo" - title: "Shells" - details: "Suporta Bash, ZSH & Fish com autocomplete." + details: "Suporta Bash, ZSH, Fish & Elvish com autocomplete." - title: "GitHub Actions" details: "Fornece um GitHub Action para instalar e utilizar seu .tool-verions em seu fluxo de trabalho CICD." # footer: MIT Licensed diff --git a/docs/pt-br/learn-more/faq.md b/docs/pt-br/learn-more/faq.md index 35cd7cca3..6847c52bc 100644 --- a/docs/pt-br/learn-more/faq.md +++ b/docs/pt-br/learn-more/faq.md @@ -1,27 +1,25 @@ -# Perguntas frequentes +# PERGUNTAS FREQUENTES -> Hi, we've recently migrated our docs and added some new pages. If you would like to help translate this page, see the "Edit this page" link at the bottom of the page. +Aqui estão algumas perguntas comuns sobre `asdf`. -Here are some common questions regarding `asdf`. +## Suporte WSL1? -## WSL1 support? +WSL1 ([Windows Subsystem for Linux](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux) 1) não é oficialmente suportado. Alguns aspectos do `asdf` podem não funcionar corretamente. Não temos a intenção de adicionar suporte oficial para WSL1. -WSL1 ([Windows Subsystem for Linux](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux) 1) is not officially supported. Some aspects of `asdf` may not work properly. We do not intend to add official support for WSL1. +## Suporte WSL2? -## WSL2 support? +WSL2 ([Subsistema Windows para Linux](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux#WSL_2) 2) deve funcionar usando as instruções de configuração e dependência para a distribuição WSL escolhida. -WSL2 ([Windows Subsystem for Linux](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux#WSL_2) 2) should work using the setup & dependency instructions for you chosen WSL distro. +É importante ressaltar que o WSL2 _apenas_ deve funcionar corretamente quando o diretório de trabalho atual é uma unidade Unix e não uma unidade Windows vinculada. -Importantly, WSL2 is _only_ expected to work properly when the current working directory is a Unix drive and not a bound Windows drive. +Pretendemos executar o conjunto de testes no WSL2 quando o suporte ao host runner estiver disponível nas Ações do GitHub; atualmente, esse não parece ser o caso. -We intend to run out test suite on WSL2 when host runner support is available on GitHub Actions, currently this does not appear to be the case. +## Exectable recém-instalado não está funcionando? -## Newly installed exectable not running? +> Acabei de instalar o `npm -g yarn`, mas não consigo executar o `yarn`. O que da? -> I just `npm install -g yarn`, but cannot execute `yarn`. What gives? +`asdf` usa [shims]() para gerenciar executáveis. Aqueles instalados por plug-ins têm shims criados automaticamente, enquanto a instalação de executáveis ​​por meio de uma ferramenta gerenciada `asdf` exigirá que você notifique o` asdf` sobre a necessidade de criar shims. Neste caso, para criar um shim para [Yarn](https://yarnpkg.com/). Veja a documentação do comando [`asdf reshim`](/ manage / core.md # reshim). -`asdf` uses [shims]() to manage executables. Those installed by plugins have shims automatically created, whereas installing executables via an `asdf` managed tool will require you to notify `asdf` of the need to create shims. In this instance, to create a shim for [Yarn](https://yarnpkg.com/). See the [`asdf reshim` command docs](/manage/core.md#reshim). +## Shell não detecta shims recém-instalados? -## Shell not detecting newly installed shims? - -If `asdf reshim` is not resolving your issue, then it is most-likely due to the sourcing of `asdf.sh` or `asdf.fish` _not_ being at the **BOTTOM** of your Shell config file (`.bash_profile`, `.zshrc`, `config.fish` etc). It needs to be sourced **AFTER** you have set your `$PATH` and **AFTER** you have sourced your framework (oh-my-zsh etc) if any. +Se `asdf reshim` não está resolvendo seu problema, então é mais provável devido ao sourcing de` asdf.sh` ou `asdf.fish` _não_ estar no ** BOTTOM ** de seu arquivo de configuração Shell (`.bash_profile`, `.zshrc`, ` config.fish`, etc). Ele precisa ser fornecido **DEPOIS** de você definir seu `$PATH` e **DEPOIS** de ter fornecido seu framework (oh-meu-zsh etc), se houver. diff --git a/docs/pt-br/manage/configuration.md b/docs/pt-br/manage/configuration.md index 49c297842..3f0c4cb0a 100644 --- a/docs/pt-br/manage/configuration.md +++ b/docs/pt-br/manage/configuration.md @@ -59,4 +59,4 @@ legacy_version_file = yes - `ASDF_CONFIG_FILE` - O padrão é `~ / .asdfrc` conforme descrito acima. Pode ser definido para qualquer local. - `ASDF_DEFAULT_TOOL_VERSIONS_FILENAME` - O nome do arquivo que armazena os nomes e versões das ferramentas. O padrão é `.tool-versions`. Pode ser qualquer nome de arquivo válido. Normalmente você não deve substituir o valor padrão, a menos que deseja que o asdf ignore os arquivos `.tool-versions`. - `ASDF_DIR` - O padrão é `~/.asdf` - Localização dos arquivos `asdf`. Se você instalar `asdf` em algum outro diretório, defina-o para esse diretório. Por exemplo, se você estiver instalando através do AUR, você deve definir isso para `/ opt / asdf-vm`. -- `ASDF_DATA_DIR` - O padrão é `~/.asdf` - Local onde `asdf` instala plugins, correções e instalações. Pode ser definido para qualquer local antes de fornecer `asdf.sh` ou`asdf.fish` mencionado na seção acima. +- `ASDF_DATA_DIR` - O padrão é `~/.asdf` - Local onde `asdf` instala plugins, correções e instalações. Pode ser definido para qualquer local antes de fornecer `asdf.sh` ou `asdf.fish` mencionado na seção acima. Para Elvish, isso pode ser definido acima de `use asdf`. diff --git a/docs/pt-br/manage/core.md b/docs/pt-br/manage/core.md index 7fd9839f7..6a36ebf69 100644 --- a/docs/pt-br/manage/core.md +++ b/docs/pt-br/manage/core.md @@ -259,6 +259,96 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc ::: +::: details Elvish & Git + +1. Em seu `~/.elvish/rc.elv` remova a linha que importa o módulo `asdf`: + +```shell +use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} +``` + +e desinstale o módulo `asdf` com este comando: + +```shell:no-line-numbers +rm -rf ~/.elvish/lib/asdf.elv +``` + +2. Remova o diretório `$HOME/.asdf`: + +```shell:no-line-numbers +if (!=s $E:ASDF_DATA_DIR "") { rm -rf $ASDF_DATA_DIR"/.asdf" } else { rm -rf ~/.asdf } +``` + +3. Execute este comando para remover todos os arquivos de configuração `asdf`: + +```shell:no-line-numbers +rm -rf $HOME/.tool-versions $HOME/.asdfrc +``` + +::: + +::: details Elvish & Homebrew + +1. Em seu `~/.elvish/rc.elv` remova a linha que importa o módulo `asdf`: + +```shell +use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} +``` + +e desinstale o módulo `asdf` com este comando: + +```shell:no-line-numbers +rm -rf ~/.elvish/lib/asdf.elv +``` + +2. Desinstale com seu gerenciador de pacotes: + +```shell:no-line-numbers +brew uninstall asdf --force +``` + +3. Execute este comando para remover todos os arquivos de configuração `asdf`: + +```shell:no-line-numbers +rm -rf $HOME/.tool-versions $HOME/.asdfrc +``` + +::: + +::: details Elvish & Pacman + +1. Em seu `~/.elvish/rc.elv` remova a linha que importa o módulo `asdf`: + +```shell +use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} +``` + +e desinstale o módulo `asdf` com este comando: + +```shell:no-line-numbers +rm -rf ~/.elvish/lib/asdf.elv +``` + +2. Desinstale com seu gerenciador de pacotes: + +```shell:no-line-numbers +pacman -Rs asdf-vm +``` + +3. Remova o diretório `$ HOME/.asdf`: + +```shell:no-line-numbers +if (!=s $E:ASDF_DATA_DIR "") { rm -rf $ASDF_DATA_DIR"/.asdf" } else { rm -rf ~/.asdf } +``` + +4. Execute este comando para remover todos os arquivos de configuração `asdf`: + +```shell:no-line-numbers +rm -rf $HOME/.tool-versions $HOME/.asdfrc +``` + +::: + ::: details ZSH & Git 1. Em seu `~/.zshrc` remova as linhas do `asdf.sh` e seus complementos: diff --git a/docs/pt-br/manage/versions.md b/docs/pt-br/manage/versions.md index aae9386e1..89a00dc23 100644 --- a/docs/pt-br/manage/versions.md +++ b/docs/pt-br/manage/versions.md @@ -133,7 +133,7 @@ asdf uninstall ## Shims -Quando asdf instala um pacote é criado _shims_ para cada programa executado no pacote do diretório `$ASDF_DATA_DIR/shims` (padrão `~/.asdf/shims`). Esse diretório começa no `$PATH` (pelos `asdf.sh` ou `asdf.fish`) é como o programa instalado é disponibilizado no ambiente do sistema. +Quando asdf instala um pacote é criado _shims_ para cada programa executado no pacote do diretório `$ASDF_DATA_DIR/shims` (padrão `~/.asdf/shims`). Esse diretório começa no `$PATH` (pelos `asdf.sh`, `asdf.fish`, etc) é como o programa instalado é disponibilizado no ambiente do sistema. Os _shims_ em si são atalhos simples que executam um programa auxiliar `asdf exec` passando o nome do plugin e o caminho para o executável no pacote instalado que o _shim_ está contido. diff --git a/lib/commands/command-export-shell-version.bash b/lib/commands/command-export-shell-version.bash index 20a5ec341..b4767b195 100644 --- a/lib/commands/command-export-shell-version.bash +++ b/lib/commands/command-export-shell-version.bash @@ -24,7 +24,10 @@ shell_command() { printf "set -e %s\\n" "$version_env_var" ;; elvish) - echo "unset-env $version_env_var" + # Elvish doesn't have a `source` command, and eval is banned, so the + # var name and value are printed on separate lines for asdf.elv to parse + # and pass to unset-env. + printf "unset-env\n$version_env_var" ;; *) printf "unset %s\\n" "$version_env_var" @@ -49,7 +52,7 @@ shell_command() { # Elvish doesn't have a `source` command, and eval is banned, so the # var name and value are printed on separate lines for asdf.elv to parse # and pass to set-env. - printf "$version_env_var\n$version" + printf "set-env\n$version_env_var\n$version" ;; *) printf "export %s=\"%s\"\\n" "$version_env_var" "$version" diff --git a/test/asdf_elvish.bats b/test/asdf_elvish.bats new file mode 100644 index 000000000..c21642459 --- /dev/null +++ b/test/asdf_elvish.bats @@ -0,0 +1,63 @@ +#!/usr/bin/env bats + +load test_helpers + +setup() { + cd $(dirname "$BATS_TEST_DIRNAME") + cp ../asdf.elv $HOME/.elvish/lib/asdftest.elv +} + +teardown() { + rm $HOME/.elvish/lib/asdftest.elv +} + +cleaned_path() { + echo $PATH | tr ':' '\n' | grep -v "asdf" | tr '\n' ' ' +} + +@test "exports ASDF_DIR" { + result=$(elvish --norc -c " + unset-env ASDF_DIR ASDF_DATA_DIR + set-env PATH $(cleaned_path) + use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} + get-env ASDF_DIR + ") + + [ "$?" -eq 0 ] + [ "$result" != "" ] +} + +@test "adds asdf dirs to PATH" { + result=$(elvish --norc -c " + unset-env ASDF_DIR ASDF_DATA_DIR + set-env PATH $(cleaned_path) + use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} + get-env PATH + ") + + output=$(echo "$result" | grep "asdf") + [ "$?" -eq 0 ] + [ "$output" != "" ] +} + +@test "defines the _asdf namespace" { + result=$(elvish --norc -c " + unset-env ASDF_DIR ASDF_DATA_DIR + set-env PATH $(cleaned_path) + use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} + pprint \$_asdf: + ") + + [[ "$output" =~ " Date: Sat, 9 Oct 2021 01:16:57 -0500 Subject: [PATCH 04/34] fix shellcheck issues --- lib/commands/command-export-shell-version.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/commands/command-export-shell-version.bash b/lib/commands/command-export-shell-version.bash index b4767b195..3403176b7 100644 --- a/lib/commands/command-export-shell-version.bash +++ b/lib/commands/command-export-shell-version.bash @@ -27,7 +27,7 @@ shell_command() { # Elvish doesn't have a `source` command, and eval is banned, so the # var name and value are printed on separate lines for asdf.elv to parse # and pass to unset-env. - printf "unset-env\n$version_env_var" + printf "unset-env\n%s" "$version_env_var" ;; *) printf "unset %s\\n" "$version_env_var" @@ -52,7 +52,7 @@ shell_command() { # Elvish doesn't have a `source` command, and eval is banned, so the # var name and value are printed on separate lines for asdf.elv to parse # and pass to set-env. - printf "set-env\n$version_env_var\n$version" + printf "set-env\n%s\n%s" "$version_env_var" "$version" ;; *) printf "export %s=\"%s\"\\n" "$version_env_var" "$version" From 6baada02e4cd32e17760a13808a53e791f5c1582 Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 01:48:27 -0500 Subject: [PATCH 05/34] Fix tests --- asdf.elv | 23 ++++++++-------- test/asdf_elvish.bats | 54 ++++++++++++++++++++++++-------------- test/asdf_fish.bats | 14 ++++------ test/version_commands.bats | 4 +-- 4 files changed, 54 insertions(+), 41 deletions(-) diff --git a/asdf.elv b/asdf.elv index 7261a7889..39e794241 100644 --- a/asdf.elv +++ b/asdf.elv @@ -1,25 +1,26 @@ use path -asdf_dir = (path:eval-symlinks (path:dir (path:eval-symlinks (src)[name]))) -set-env ASDF_DIR $asdf_dir +if (not (has-env ASDF_DIR)) { + set-env ASDF_DIR $E:HOME"/.asdf" +} -var asdf_user_shims -if (and (has-env "ASDF_DATA_DIR") (not (== $E:ASDF_DATA_DIR ""))) { - asdf_user_shims = $E:ASDF_DATA_DIR/shims +var asdf_shims_dir +if (and (has-env ASDF_DATA_DIR) (not (==s $E:ASDF_DATA_DIR ""))) { + asdf_shims_dir = $E:ASDF_DATA_DIR"/shims" } else { - asdf_user_shims = $asdf_dir/shims + asdf_shims_dir = $E:ASDF_DIR"/shims" } -# Add shims to PATH -if (not (has-value $paths $asdf_user_shims)) { - paths = [$@paths $asdf_user_shims] +# Append shims to PATH +if (not (has-value $paths $asdf_shims_dir)) { + paths = [$@paths $asdf_shims_dir] } # Add function wrapper so we can export variables fn asdf [command @args]{ if (==s $command "shell") { # set environment variables - parts = [($asdf_dir"/bin/asdf" export-shell-version elvish $@args)] + parts = [($E:ASDF_DIR"/bin/asdf" export-shell-version elvish $@args)] if (==s $parts[0] "set-env") { set-env $parts[1] $parts[2] } elif (==s $parts[0] "unset-env") { @@ -27,6 +28,6 @@ fn asdf [command @args]{ } } else { # forward other commands to asdf script - command $asdf_dir"/bin/asdf" $command $@args + command $E:ASDF_DIR"/bin/asdf" $command $@args } } diff --git a/test/asdf_elvish.bats b/test/asdf_elvish.bats index c21642459..d2cf1727a 100644 --- a/test/asdf_elvish.bats +++ b/test/asdf_elvish.bats @@ -4,7 +4,7 @@ load test_helpers setup() { cd $(dirname "$BATS_TEST_DIRNAME") - cp ../asdf.elv $HOME/.elvish/lib/asdftest.elv + cp ./asdf.elv $HOME/.elvish/lib/asdftest.elv } teardown() { @@ -16,48 +16,64 @@ cleaned_path() { } @test "exports ASDF_DIR" { - result=$(elvish --norc -c " - unset-env ASDF_DIR ASDF_DATA_DIR - set-env PATH $(cleaned_path) + output=$(elvish --norc -c " + unset-env ASDF_DIR + unset-env ASDF_DATA_DIR + paths = [$(cleaned_path)] use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} - get-env ASDF_DIR + echo \$E:ASDF_DIR ") + [ "$?" -eq 0 ] + [ "$output" = "$HOME/.asdf" ] +} +@test "retains ASDF_DIR" { + output=$(elvish --norc -c " + set-env ASDF_DIR "/path/to/asdf" + unset-env ASDF_DATA_DIR + paths = [$(cleaned_path)] + use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} + echo \$E:ASDF_DIR + ") [ "$?" -eq 0 ] - [ "$result" != "" ] + [ "$output" = "/path/to/asdf" ] } @test "adds asdf dirs to PATH" { result=$(elvish --norc -c " - unset-env ASDF_DIR ASDF_DATA_DIR - set-env PATH $(cleaned_path) + unset-env ASDF_DIR + unset-env ASDF_DATA_DIR + paths = [$(cleaned_path)] use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} - get-env PATH + echo \$E:PATH ") - - output=$(echo "$result" | grep "asdf") [ "$?" -eq 0 ] + echo "$result" + output=$(echo "$result" | grep "asdf") [ "$output" != "" ] } @test "defines the _asdf namespace" { - result=$(elvish --norc -c " - unset-env ASDF_DIR ASDF_DATA_DIR - set-env PATH $(cleaned_path) + output=$(elvish --norc -c " + unset-env ASDF_DIR + unset-env ASDF_DATA_DIR + paths = [$(cleaned_path)] use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} pprint \$_asdf: ") - + [ "$?" -eq 0 ] [[ "$output" =~ " Date: Sat, 9 Oct 2021 01:50:57 -0500 Subject: [PATCH 06/34] Fix test --- test/asdf_elvish.bats | 1 + 1 file changed, 1 insertion(+) diff --git a/test/asdf_elvish.bats b/test/asdf_elvish.bats index d2cf1727a..c5f982d2b 100644 --- a/test/asdf_elvish.bats +++ b/test/asdf_elvish.bats @@ -4,6 +4,7 @@ load test_helpers setup() { cd $(dirname "$BATS_TEST_DIRNAME") + mkdir -p $HOME/.elvish/lib cp ./asdf.elv $HOME/.elvish/lib/asdftest.elv } From 5bb00bb3b2974f7e4872b8e22bbf7411484fc167 Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 01:52:28 -0500 Subject: [PATCH 07/34] Fix other test --- asdf.fish | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/asdf.fish b/asdf.fish index 157363013..073bd5f71 100644 --- a/asdf.fish +++ b/asdf.fish @@ -2,9 +2,9 @@ set -x ASDF_DIR (dirname (status -f)) set -l asdf_user_shims ( if test -n "$ASDF_DATA_DIR" - echo $ASDF_DATA_DIR/shims + printf $ASDF_DATA_DIR/shims else - echo $HOME/.asdf/shims + printf $HOME/.asdf/shims end ) From 1f1f570b4a2df43743c4d314aefd7cc0f579dcdf Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 01:55:51 -0500 Subject: [PATCH 08/34] Fix tests on older elvish --- test/asdf_elvish.bats | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/asdf_elvish.bats b/test/asdf_elvish.bats index c5f982d2b..d399a450d 100644 --- a/test/asdf_elvish.bats +++ b/test/asdf_elvish.bats @@ -17,7 +17,7 @@ cleaned_path() { } @test "exports ASDF_DIR" { - output=$(elvish --norc -c " + output=$(elvish -c " unset-env ASDF_DIR unset-env ASDF_DATA_DIR paths = [$(cleaned_path)] @@ -29,7 +29,7 @@ cleaned_path() { } @test "retains ASDF_DIR" { - output=$(elvish --norc -c " + output=$(elvish -c " set-env ASDF_DIR "/path/to/asdf" unset-env ASDF_DATA_DIR paths = [$(cleaned_path)] @@ -41,7 +41,7 @@ cleaned_path() { } @test "adds asdf dirs to PATH" { - result=$(elvish --norc -c " + result=$(elvish -c " unset-env ASDF_DIR unset-env ASDF_DATA_DIR paths = [$(cleaned_path)] @@ -55,7 +55,7 @@ cleaned_path() { } @test "defines the _asdf namespace" { - output=$(elvish --norc -c " + output=$(elvish -c " unset-env ASDF_DIR unset-env ASDF_DATA_DIR paths = [$(cleaned_path)] @@ -67,7 +67,7 @@ cleaned_path() { } @test "defines the asdf function" { - output=$(elvish --norc -c " + output=$(elvish -c " unset-env ASDF_DIR unset-env ASDF_DATA_DIR paths = [$(cleaned_path)] From dfdb59c4cdfd98653930e545e19f047943aa70db Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 01:57:37 -0500 Subject: [PATCH 09/34] Fix test --- asdf.elv | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/asdf.elv b/asdf.elv index 39e794241..f10fe3d44 100644 --- a/asdf.elv +++ b/asdf.elv @@ -4,14 +4,11 @@ if (not (has-env ASDF_DIR)) { set-env ASDF_DIR $E:HOME"/.asdf" } -var asdf_shims_dir +# Append shims to PATH +var asdf_shims_dir = $E:ASDF_DIR"/shims" if (and (has-env ASDF_DATA_DIR) (not (==s $E:ASDF_DATA_DIR ""))) { asdf_shims_dir = $E:ASDF_DATA_DIR"/shims" -} else { - asdf_shims_dir = $E:ASDF_DIR"/shims" } - -# Append shims to PATH if (not (has-value $paths $asdf_shims_dir)) { paths = [$@paths $asdf_shims_dir] } From 8f7ea81b80d7b7785643bed4a5cf693a3f142a4a Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 02:17:38 -0500 Subject: [PATCH 10/34] Install newer elvish --- .github/workflows/tests.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 77aeda7df..5c29934d9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -33,10 +33,14 @@ jobs: - name: Install test dependencies if: runner.os == 'linux' run: | - PPA="ppa:fish-shell/nightly-master" - sudo add-apt-repository -y "$PPA" + sudo add-apt-repository -y ppa:fish-shell/nightly-master + sudo add-apt-repository -y ppa:longsleep/golang-backports sudo apt-get update - sudo apt-get -y install fish elvish + sudo apt-get -y install fish golang-go + git clone --depth 1 --single-branch https://github.com/elves/elvish + cd elvish + make get + echo "$HOME/go/bin" >>"$GITHUB_PATH" - name: Install bats run: | From b05968f3e4933eab7f7defa87b8041377b5e191e Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 02:19:21 -0500 Subject: [PATCH 11/34] Fix test --- asdf.sh | 2 +- test/asdf_elvish.bats | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/asdf.sh b/asdf.sh index 7450c183b..fe3825ab2 100644 --- a/asdf.sh +++ b/asdf.sh @@ -14,7 +14,7 @@ fi export ASDF_DIR ASDF_DIR="$(dirname "$current_script_path")" # shellcheck disable=SC2016 -[ -d "$ASDF_DIR" ] || echo '$ASDF_DIR is not a directory' +[ -d "$ASDF_DIR" ] || printf '$ASDF_DIR is not a directory' # Add asdf to PATH # diff --git a/test/asdf_elvish.bats b/test/asdf_elvish.bats index d399a450d..c5f982d2b 100644 --- a/test/asdf_elvish.bats +++ b/test/asdf_elvish.bats @@ -17,7 +17,7 @@ cleaned_path() { } @test "exports ASDF_DIR" { - output=$(elvish -c " + output=$(elvish --norc -c " unset-env ASDF_DIR unset-env ASDF_DATA_DIR paths = [$(cleaned_path)] @@ -29,7 +29,7 @@ cleaned_path() { } @test "retains ASDF_DIR" { - output=$(elvish -c " + output=$(elvish --norc -c " set-env ASDF_DIR "/path/to/asdf" unset-env ASDF_DATA_DIR paths = [$(cleaned_path)] @@ -41,7 +41,7 @@ cleaned_path() { } @test "adds asdf dirs to PATH" { - result=$(elvish -c " + result=$(elvish --norc -c " unset-env ASDF_DIR unset-env ASDF_DATA_DIR paths = [$(cleaned_path)] @@ -55,7 +55,7 @@ cleaned_path() { } @test "defines the _asdf namespace" { - output=$(elvish -c " + output=$(elvish --norc -c " unset-env ASDF_DIR unset-env ASDF_DATA_DIR paths = [$(cleaned_path)] @@ -67,7 +67,7 @@ cleaned_path() { } @test "defines the asdf function" { - output=$(elvish -c " + output=$(elvish --norc -c " unset-env ASDF_DIR unset-env ASDF_DATA_DIR paths = [$(cleaned_path)] From 8c7fb68d6c37b7e56ded9d36f1ae2c15e7c79f9d Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 02:24:20 -0500 Subject: [PATCH 12/34] Add test for running command --- lib/commands/command-info.bash | 2 +- test/asdf_elvish.bats | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/commands/command-info.bash b/lib/commands/command-info.bash index 2c6c3fc80..001058667 100644 --- a/lib/commands/command-info.bash +++ b/lib/commands/command-info.bash @@ -5,7 +5,7 @@ info_command() { printf "%s:\\n%s\\n\\n" "SHELL" "$($SHELL --version)" printf "%s:\\n%s\\n\\n" "ASDF VERSION" "$(asdf_version)" printf "%s:\\n%s\\n\\n" "ASDF ENVIRONMENT VARIABLES" "$(env | grep -E "ASDF_DIR|ASDF_DATA_DIR|ASDF_CONFIG_FILE|ASDF_DEFAULT_TOOL_VERSIONS_FILENAME")" - printf "%s:\\n%s\\n\\n" "ASDF INSTALLED PLUGINS" "$(asdf plugin list --urls --refs)" + printf "%s:\\n%s\\n\\n" "ASDF INSTALLED PLUGINS" "$($ASDF_DIR/bin/asdf plugin list --urls --refs)" } info_command "$@" diff --git a/test/asdf_elvish.bats b/test/asdf_elvish.bats index c5f982d2b..557f1daa6 100644 --- a/test/asdf_elvish.bats +++ b/test/asdf_elvish.bats @@ -78,3 +78,16 @@ cleaned_path() { echo "$output" [[ "$output" =~ " Date: Sat, 9 Oct 2021 02:26:02 -0500 Subject: [PATCH 13/34] Add test for running asdf subcommands --- test/asdf_elvish.bats | 2 +- test/asdf_fish.bats | 15 +++++++++++++++ test/asdf_sh.bats | 14 ++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/test/asdf_elvish.bats b/test/asdf_elvish.bats index 557f1daa6..db8869607 100644 --- a/test/asdf_elvish.bats +++ b/test/asdf_elvish.bats @@ -79,7 +79,7 @@ cleaned_path() { [[ "$output" =~ " Date: Sat, 9 Oct 2021 02:29:42 -0500 Subject: [PATCH 14/34] Linter --- lib/commands/command-info.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/commands/command-info.bash b/lib/commands/command-info.bash index 001058667..025cd7bfd 100644 --- a/lib/commands/command-info.bash +++ b/lib/commands/command-info.bash @@ -5,7 +5,7 @@ info_command() { printf "%s:\\n%s\\n\\n" "SHELL" "$($SHELL --version)" printf "%s:\\n%s\\n\\n" "ASDF VERSION" "$(asdf_version)" printf "%s:\\n%s\\n\\n" "ASDF ENVIRONMENT VARIABLES" "$(env | grep -E "ASDF_DIR|ASDF_DATA_DIR|ASDF_CONFIG_FILE|ASDF_DEFAULT_TOOL_VERSIONS_FILENAME")" - printf "%s:\\n%s\\n\\n" "ASDF INSTALLED PLUGINS" "$($ASDF_DIR/bin/asdf plugin list --urls --refs)" + printf "%s:\\n%s\\n\\n" "ASDF INSTALLED PLUGINS" "$("$ASDF_DIR/bin/asdf" plugin list --urls --refs)" } info_command "$@" From 5186c1afcad3ad1adbb1b4f51fba508758b0c0c3 Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 02:30:57 -0500 Subject: [PATCH 15/34] Remove command keyword --- asdf.elv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asdf.elv b/asdf.elv index f10fe3d44..0f3bee515 100644 --- a/asdf.elv +++ b/asdf.elv @@ -25,6 +25,6 @@ fn asdf [command @args]{ } } else { # forward other commands to asdf script - command $E:ASDF_DIR"/bin/asdf" $command $@args + $E:ASDF_DIR"/bin/asdf" $command $@args } } From cec89d7d64e6871addd7d05920bab011d753b1ba Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 02:45:34 -0500 Subject: [PATCH 16/34] Fix test --- .github/workflows/tests.yml | 2 ++ asdf.elv | 2 +- test/asdf_elvish.bats | 8 +------- test/asdf_fish.bats | 2 +- test/asdf_sh.bats | 2 +- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5c29934d9..3b4468bee 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -37,6 +37,8 @@ jobs: sudo add-apt-repository -y ppa:longsleep/golang-backports sudo apt-get update sudo apt-get -y install fish golang-go + + # Build elvish and add to path git clone --depth 1 --single-branch https://github.com/elves/elvish cd elvish make get diff --git a/asdf.elv b/asdf.elv index 0f3bee515..f10fe3d44 100644 --- a/asdf.elv +++ b/asdf.elv @@ -25,6 +25,6 @@ fn asdf [command @args]{ } } else { # forward other commands to asdf script - $E:ASDF_DIR"/bin/asdf" $command $@args + command $E:ASDF_DIR"/bin/asdf" $command $@args } } diff --git a/test/asdf_elvish.bats b/test/asdf_elvish.bats index db8869607..98e10b174 100644 --- a/test/asdf_elvish.bats +++ b/test/asdf_elvish.bats @@ -19,7 +19,6 @@ cleaned_path() { @test "exports ASDF_DIR" { output=$(elvish --norc -c " unset-env ASDF_DIR - unset-env ASDF_DATA_DIR paths = [$(cleaned_path)] use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} echo \$E:ASDF_DIR @@ -31,7 +30,6 @@ cleaned_path() { @test "retains ASDF_DIR" { output=$(elvish --norc -c " set-env ASDF_DIR "/path/to/asdf" - unset-env ASDF_DATA_DIR paths = [$(cleaned_path)] use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} echo \$E:ASDF_DIR @@ -43,7 +41,6 @@ cleaned_path() { @test "adds asdf dirs to PATH" { result=$(elvish --norc -c " unset-env ASDF_DIR - unset-env ASDF_DATA_DIR paths = [$(cleaned_path)] use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} echo \$E:PATH @@ -57,7 +54,6 @@ cleaned_path() { @test "defines the _asdf namespace" { output=$(elvish --norc -c " unset-env ASDF_DIR - unset-env ASDF_DATA_DIR paths = [$(cleaned_path)] use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} pprint \$_asdf: @@ -69,7 +65,6 @@ cleaned_path() { @test "defines the asdf function" { output=$(elvish --norc -c " unset-env ASDF_DIR - unset-env ASDF_DATA_DIR paths = [$(cleaned_path)] use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} pprint \$asdf~ @@ -81,8 +76,7 @@ cleaned_path() { @test "function calls asdf command" { result=$(elvish --norc -c " - unset-env ASDF_DIR - unset-env ASDF_DATA_DIR + set-env ASDF_DIR $(pwd) paths = [$(cleaned_path)] use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} asdf info diff --git a/test/asdf_fish.bats b/test/asdf_fish.bats index 3e6b3e109..6ffa6997d 100644 --- a/test/asdf_fish.bats +++ b/test/asdf_fish.bats @@ -71,7 +71,7 @@ cleaned_path() { @test "function calls asdf command" { result=$(fish -c " set -e asdf - set -e ASDF_DIR + set -x ASDF_DIR $(pwd) set PATH $(cleaned_path) . asdf.fish diff --git a/test/asdf_sh.bats b/test/asdf_sh.bats index 1f92dafd0..02ff44a6c 100644 --- a/test/asdf_sh.bats +++ b/test/asdf_sh.bats @@ -73,7 +73,7 @@ cleaned_path() { @test "function calls asdf command" { result=$( unset -f asdf - unset ASDF_DIR + ASDF_DIR=$(pwd) PATH=$(cleaned_path) source_asdf_sh From 6b49ba274752d540296b9f3ff972e87e80fcdc29 Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 02:48:30 -0500 Subject: [PATCH 17/34] Fix test --- asdf.elv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asdf.elv b/asdf.elv index f10fe3d44..0f3bee515 100644 --- a/asdf.elv +++ b/asdf.elv @@ -25,6 +25,6 @@ fn asdf [command @args]{ } } else { # forward other commands to asdf script - command $E:ASDF_DIR"/bin/asdf" $command $@args + $E:ASDF_DIR"/bin/asdf" $command $@args } } From 207f1c1db1357fc08479eb8862e7f276d4362d71 Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 02:50:38 -0500 Subject: [PATCH 18/34] -norc --- test/asdf_elvish.bats | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/asdf_elvish.bats b/test/asdf_elvish.bats index 98e10b174..22ec863f8 100644 --- a/test/asdf_elvish.bats +++ b/test/asdf_elvish.bats @@ -17,7 +17,7 @@ cleaned_path() { } @test "exports ASDF_DIR" { - output=$(elvish --norc -c " + output=$(elvish -norc -c " unset-env ASDF_DIR paths = [$(cleaned_path)] use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} @@ -28,7 +28,7 @@ cleaned_path() { } @test "retains ASDF_DIR" { - output=$(elvish --norc -c " + output=$(elvish -norc -c " set-env ASDF_DIR "/path/to/asdf" paths = [$(cleaned_path)] use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} @@ -39,7 +39,7 @@ cleaned_path() { } @test "adds asdf dirs to PATH" { - result=$(elvish --norc -c " + result=$(elvish -norc -c " unset-env ASDF_DIR paths = [$(cleaned_path)] use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} @@ -52,7 +52,7 @@ cleaned_path() { } @test "defines the _asdf namespace" { - output=$(elvish --norc -c " + output=$(elvish -norc -c " unset-env ASDF_DIR paths = [$(cleaned_path)] use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} @@ -63,7 +63,7 @@ cleaned_path() { } @test "defines the asdf function" { - output=$(elvish --norc -c " + output=$(elvish -norc -c " unset-env ASDF_DIR paths = [$(cleaned_path)] use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} @@ -75,7 +75,7 @@ cleaned_path() { } @test "function calls asdf command" { - result=$(elvish --norc -c " + result=$(elvish -norc -c " set-env ASDF_DIR $(pwd) paths = [$(cleaned_path)] use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} From 384f450139fc18918acefa77372d656c8703b616 Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 16:42:17 -0500 Subject: [PATCH 19/34] Add completions --- asdf.elv | 36 +++++--- completions/asdf.elv | 192 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 215 insertions(+), 13 deletions(-) create mode 100644 completions/asdf.elv diff --git a/asdf.elv b/asdf.elv index 0f3bee515..560f58416 100644 --- a/asdf.elv +++ b/asdf.elv @@ -1,30 +1,40 @@ use path -if (not (has-env ASDF_DIR)) { - set-env ASDF_DIR $E:HOME"/.asdf" +var asdf_dir = $E:HOME'/.asdf' +if (and (has-env ASDF_DIR) (!=s $E:ASDF_DIR '')) { + asdf_dir = $E:ASDF_DIR } -# Append shims to PATH -var asdf_shims_dir = $E:ASDF_DIR"/shims" -if (and (has-env ASDF_DATA_DIR) (not (==s $E:ASDF_DATA_DIR ""))) { - asdf_shims_dir = $E:ASDF_DATA_DIR"/shims" +var asdf_data_dir = $asdf_dir +if (and (has-env ASDF_DATA_DIR) (!=s $E:ASDF_DATA_DIR '')) { + asdf_data_dir = $E:ASDF_DATA_DIR } -if (not (has-value $paths $asdf_shims_dir)) { - paths = [$@paths $asdf_shims_dir] + +# Append ~/.asdf/bin and ~/.asdf/shims to PATH +for path [ + $asdf_dir'/bin' + $asdf_data_dir'/shims' +] { + if (not (has-value $paths $path)) { + paths = [ + $@paths + $path + ] + } } # Add function wrapper so we can export variables fn asdf [command @args]{ - if (==s $command "shell") { + if (==s $command 'shell') { # set environment variables - parts = [($E:ASDF_DIR"/bin/asdf" export-shell-version elvish $@args)] - if (==s $parts[0] "set-env") { + parts = [($asdf_dir'/bin/asdf' export-shell-version elvish $@args)] + if (==s $parts[0] 'set-env') { set-env $parts[1] $parts[2] - } elif (==s $parts[0] "unset-env") { + } elif (==s $parts[0] 'unset-env') { unset-env $parts[1] } } else { # forward other commands to asdf script - $E:ASDF_DIR"/bin/asdf" $command $@args + $asdf_dir'/bin/asdf' $command $@args } } diff --git a/completions/asdf.elv b/completions/asdf.elv new file mode 100644 index 000000000..15ee79bed --- /dev/null +++ b/completions/asdf.elv @@ -0,0 +1,192 @@ +use re +use str +use asdf _asdf +use path + +fn match [argz name]{ + try { + var num = (count $argz) + if (== $num 0) { + ==s $name '' + } elif (==s $name $argz[0]) { + == $num 1 + } else { + ==s $name (str:join '-' $argz) + } + } except err { + echo '$err' + } +} + +fn match-nested [argz name @pattern]{ + try { + var num_pat = (count $pattern) + var i = 0 + var matched = $true + if (match $argz[:(- 0 $num_pat)] $name) { + var nested = $argz[(- 0 $num_pat):] + if (== (count $nested) (count $pattern)) { + for pat [$@pattern] { + if (and (!=s $pat '*') (==s $pat $nested[$i])) { + matched = $false + break + } + i = (+ $i 1) + } + } + } else { + matched = $false + } + put $matched + } except err { + echo '$err' + } +} + +fn ls-shims []{ + ls $_asdf:asdf_data_dir'/shims' +} + +fn ls-executables []{ + # Print all executable files and links in path + try { + find $@paths '(' -type f -o -type l ')' -print 2>/dev/null | each [p]{ + try { + if (test -x $p) { + path:base $p + } + } except { } + } + } except { } +} + +fn ls-installed-versions [plugin_name]{ + _asdf:asdf list $plugin_name | each [version]{ + put (re:replace '^\s*(.*)\s*' '${1}' $version) + } +} + +fn ls-all-versions [plugin_name]{ + _asdf:asdf list-all $plugin_name | each [version]{ + put (re:replace '^\s*(.*)\s*' '${1}' $version) + } +} + +set edit:completion:arg-completer[asdf] = [@argz]{ + # Argument completion for for asdf + + # strip 'asdf' and trailing empty string + argz = $argz[1:-1] + var num = (count $argz) + if (== $num 0) { + # list all subcommands + find $_asdf:asdf_dir'/lib/commands' -name 'command-*' | each [cmd]{ + put (re:replace '.*/command-(.*)\.bash' '${1}' $cmd) + } + put 'plugin' + put 'list' + } else { + if (match $argz 'current') { + # asdf current + _asdf:asdf plugin-list + } elif (match $argz 'env') { + # asdf env + ls-shims + } elif (match-nested $argz 'env' '*') { + # asdf env [util] + ls-executables + } elif (match $argz 'exec') { + # asdf exec + ls-shims + } elif (match $argz 'global') { + # asdf global + _asdf:asdf plugin-list + } elif (match-nested $argz 'global' '*') { + # asdf global + ls-installed-versions $argz[-1] + } elif (match $argz 'install') { + # asdf install + _asdf:asdf plugin-list + } elif (match-nested $argz 'install' '*') { + # asdf install + ls-all-versions $argz[-1] + } elif (match $argz 'latest') { + # asdf latest + _asdf:asdf plugin-list + } elif (match-nested $argz 'latest' '*') { + # asdf latest [] + ls-all-versions $argz[-1] + } elif (match $argz 'list-all') { + # asdf list all + _asdf:asdf plugin-list + } elif (match-nested $argz 'list-all' '*') { + # asdf list all [] + ls-all-versions $argz[-1] + } elif (match $argz 'list') { + # asdf list + _asdf:asdf plugin-list + } elif (match-nested $argz 'list' '*') { + # asdf list [] + ls-installed-versions $argz[-1] + } elif (match $argz 'local') { + # asdf local + _asdf:asdf plugin-list + } elif (match-nested $argz 'local' '*') { + # asdf local [] + ls-installed-versions $argz[-1] + } elif (match $argz 'plugin-add') { + # asdf plugin add + _asdf:asdf plugin-list-all | each [line]{ + put (re:replace '([^\s]+)\s+.*' '${1}' $line) + } + } elif (match $argz 'plugin-list') { + # asdf plugin list + put '--urls' + put '--refs' + put 'all' + } elif (match $argz 'plugin-push') { + # asdf plugin push + _asdf:asdf plugin-list + } elif (match $argz 'plugin-remove') { + # asdf plugin remove + _asdf:asdf plugin-list + } elif (match $argz 'plugin-update') { + # asdf plugin update + _asdf:asdf plugin-list + put '--all' + } elif (match $argz 'plugin') { + # list plugin-* subcommands + find $_asdf:asdf_dir'/lib/commands' -name 'command-plugin-*' | each [cmd]{ + put (re:replace '.*/command-plugin-(.*)\.bash' '${1}' $cmd) + } + } elif (match $argz 'reshim') { + # asdf reshim + _asdf:asdf plugin-list + } elif (match-nested $argz 'reshim' '*') { + # asdf reshim + ls-installed-versions $argz[-1] + } elif (match $argz 'shim-versions') { + # asdf shim-versions + ls-shims + } elif (match $argz 'uninstall') { + # asdf uninstall + _asdf:asdf plugin-list + } elif (match-nested $argz 'uninstall' '*') { + # asdf uninstall + ls-installed-versions $argz[-1] + } elif (match $argz 'update') { + if (== $num 1) { + # asdf update + put '--head' + } + } elif (match $argz 'where') { + # asdf where + _asdf:asdf plugin-list + } elif (match-nested $argz 'where' '*') { + # asdf where [] + ls-installed-versions $argz[-1] + } elif (match $argz 'which') { + ls-shims + } + } +} From 02069ff717e05f57758435d14d2ce9adf1e5c6aa Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 16:57:07 -0500 Subject: [PATCH 20/34] Fix test --- asdf.elv | 2 ++ 1 file changed, 2 insertions(+) diff --git a/asdf.elv b/asdf.elv index 560f58416..7d8cef7d7 100644 --- a/asdf.elv +++ b/asdf.elv @@ -3,6 +3,8 @@ use path var asdf_dir = $E:HOME'/.asdf' if (and (has-env ASDF_DIR) (!=s $E:ASDF_DIR '')) { asdf_dir = $E:ASDF_DIR +} else { + set-env ASDF_DIR $asdf_dir } var asdf_data_dir = $asdf_dir From 9ba6749f19a63e2eb945d6de88519ab89d31549f Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 17:17:00 -0500 Subject: [PATCH 21/34] Single module for asdf function & completions Update docs --- asdf.elv | 211 ++++++++++++++++++++++++++-- completions/asdf.elv | 192 ------------------------- docs/guide/getting-started.md | 13 +- docs/pt-br/guide/getting-started.md | 37 +++++ docs/pt-br/learn-more/faq.md | 2 +- 5 files changed, 245 insertions(+), 210 deletions(-) delete mode 100644 completions/asdf.elv diff --git a/asdf.elv b/asdf.elv index 7d8cef7d7..a70c8e18e 100644 --- a/asdf.elv +++ b/asdf.elv @@ -1,3 +1,6 @@ + +use re +use str use path var asdf_dir = $E:HOME'/.asdf' @@ -12,6 +15,91 @@ if (and (has-env ASDF_DATA_DIR) (!=s $E:ASDF_DATA_DIR '')) { asdf_data_dir = $E:ASDF_DATA_DIR } +# Add function wrapper so we can export variables +fn asdf [command @args]{ + if (==s $command 'shell') { + # set environment variables + parts = [($asdf_dir'/bin/asdf' export-shell-version elvish $@args)] + if (==s $parts[0] 'set-env') { + set-env $parts[1] $parts[2] + } elif (==s $parts[0] 'unset-env') { + unset-env $parts[1] + } + } else { + # forward other commands to asdf script + $asdf_dir'/bin/asdf' $command $@args + } +} + +fn match [argz name]{ + try { + var num = (count $argz) + if (== $num 0) { + ==s $name '' + } elif (==s $name $argz[0]) { + == $num 1 + } else { + ==s $name (str:join '-' $argz) + } + } except err { + echo '$err' + } +} + +fn match-nested [argz name @pattern]{ + try { + var num_pat = (count $pattern) + var i = 0 + var matched = $true + if (match $argz[:(- 0 $num_pat)] $name) { + var nested = $argz[(- 0 $num_pat):] + if (== (count $nested) (count $pattern)) { + for pat [$@pattern] { + if (and (!=s $pat '*') (==s $pat $nested[$i])) { + matched = $false + break + } + i = (+ $i 1) + } + } + } else { + matched = $false + } + put $matched + } except err { + echo '$err' + } +} + +fn ls-shims []{ + ls $asdf_data_dir'/shims' +} + +fn ls-executables []{ + # Print all executable files and links in path + try { + find $@paths '(' -type f -o -type l ')' -print 2>/dev/null | each [p]{ + try { + if (test -x $p) { + path:base $p + } + } except { } + } + } except { } +} + +fn ls-installed-versions [plugin_name]{ + asdf list $plugin_name | each [version]{ + put (re:replace '^\s*(.*)\s*' '${1}' $version) + } +} + +fn ls-all-versions [plugin_name]{ + asdf list-all $plugin_name | each [version]{ + put (re:replace '^\s*(.*)\s*' '${1}' $version) + } +} + # Append ~/.asdf/bin and ~/.asdf/shims to PATH for path [ $asdf_dir'/bin' @@ -25,18 +113,119 @@ for path [ } } -# Add function wrapper so we can export variables -fn asdf [command @args]{ - if (==s $command 'shell') { - # set environment variables - parts = [($asdf_dir'/bin/asdf' export-shell-version elvish $@args)] - if (==s $parts[0] 'set-env') { - set-env $parts[1] $parts[2] - } elif (==s $parts[0] 'unset-env') { - unset-env $parts[1] +# Setup argument completions +set edit:completion:arg-completer[asdf] = [@argz]{ + argz = $argz[1:-1] # strip 'asdf' and trailing empty string + var num = (count $argz) + if (== $num 0) { + # list all subcommands + find $asdf_dir'/lib/commands' -name 'command-*' | each [cmd]{ + put (re:replace '.*/command-(.*)\.bash' '${1}' $cmd) } + put 'plugin' + put 'list' } else { - # forward other commands to asdf script - $asdf_dir'/bin/asdf' $command $@args + if (match $argz 'current') { + # asdf current + asdf plugin-list + } elif (match $argz 'env') { + # asdf env + ls-shims + } elif (match-nested $argz 'env' '*') { + # asdf env [util] + ls-executables + } elif (match $argz 'exec') { + # asdf exec + ls-shims + } elif (match $argz 'global') { + # asdf global + asdf plugin-list + } elif (match-nested $argz 'global' '*') { + # asdf global + ls-installed-versions $argz[-1] + } elif (match $argz 'install') { + # asdf install + asdf plugin-list + } elif (match-nested $argz 'install' '*') { + # asdf install + ls-all-versions $argz[-1] + } elif (match $argz 'latest') { + # asdf latest + asdf plugin-list + } elif (match-nested $argz 'latest' '*') { + # asdf latest [] + ls-all-versions $argz[-1] + } elif (match $argz 'list-all') { + # asdf list all + asdf plugin-list + } elif (match-nested $argz 'list-all' '*') { + # asdf list all [] + ls-all-versions $argz[-1] + } elif (match $argz 'list') { + # asdf list + asdf plugin-list + } elif (match-nested $argz 'list' '*') { + # asdf list [] + ls-installed-versions $argz[-1] + } elif (match $argz 'local') { + # asdf local + asdf plugin-list + } elif (match-nested $argz 'local' '*') { + # asdf local [] + ls-installed-versions $argz[-1] + } elif (match $argz 'plugin-add') { + # asdf plugin add + asdf plugin-list-all | each [line]{ + put (re:replace '([^\s]+)\s+.*' '${1}' $line) + } + } elif (match $argz 'plugin-list') { + # asdf plugin list + put '--urls' + put '--refs' + put 'all' + } elif (match $argz 'plugin-push') { + # asdf plugin push + asdf plugin-list + } elif (match $argz 'plugin-remove') { + # asdf plugin remove + asdf plugin-list + } elif (match $argz 'plugin-update') { + # asdf plugin update + asdf plugin-list + put '--all' + } elif (match $argz 'plugin') { + # list plugin-* subcommands + find $asdf_dir'/lib/commands' -name 'command-plugin-*' | each [cmd]{ + put (re:replace '.*/command-plugin-(.*)\.bash' '${1}' $cmd) + } + } elif (match $argz 'reshim') { + # asdf reshim + asdf plugin-list + } elif (match-nested $argz 'reshim' '*') { + # asdf reshim + ls-installed-versions $argz[-1] + } elif (match $argz 'shim-versions') { + # asdf shim-versions + ls-shims + } elif (match $argz 'uninstall') { + # asdf uninstall + asdf plugin-list + } elif (match-nested $argz 'uninstall' '*') { + # asdf uninstall + ls-installed-versions $argz[-1] + } elif (match $argz 'update') { + if (== $num 1) { + # asdf update + put '--head' + } + } elif (match $argz 'where') { + # asdf where + asdf plugin-list + } elif (match-nested $argz 'where' '*') { + # asdf where [] + ls-installed-versions $argz[-1] + } elif (match $argz 'which') { + ls-shims + } } } diff --git a/completions/asdf.elv b/completions/asdf.elv deleted file mode 100644 index 15ee79bed..000000000 --- a/completions/asdf.elv +++ /dev/null @@ -1,192 +0,0 @@ -use re -use str -use asdf _asdf -use path - -fn match [argz name]{ - try { - var num = (count $argz) - if (== $num 0) { - ==s $name '' - } elif (==s $name $argz[0]) { - == $num 1 - } else { - ==s $name (str:join '-' $argz) - } - } except err { - echo '$err' - } -} - -fn match-nested [argz name @pattern]{ - try { - var num_pat = (count $pattern) - var i = 0 - var matched = $true - if (match $argz[:(- 0 $num_pat)] $name) { - var nested = $argz[(- 0 $num_pat):] - if (== (count $nested) (count $pattern)) { - for pat [$@pattern] { - if (and (!=s $pat '*') (==s $pat $nested[$i])) { - matched = $false - break - } - i = (+ $i 1) - } - } - } else { - matched = $false - } - put $matched - } except err { - echo '$err' - } -} - -fn ls-shims []{ - ls $_asdf:asdf_data_dir'/shims' -} - -fn ls-executables []{ - # Print all executable files and links in path - try { - find $@paths '(' -type f -o -type l ')' -print 2>/dev/null | each [p]{ - try { - if (test -x $p) { - path:base $p - } - } except { } - } - } except { } -} - -fn ls-installed-versions [plugin_name]{ - _asdf:asdf list $plugin_name | each [version]{ - put (re:replace '^\s*(.*)\s*' '${1}' $version) - } -} - -fn ls-all-versions [plugin_name]{ - _asdf:asdf list-all $plugin_name | each [version]{ - put (re:replace '^\s*(.*)\s*' '${1}' $version) - } -} - -set edit:completion:arg-completer[asdf] = [@argz]{ - # Argument completion for for asdf - - # strip 'asdf' and trailing empty string - argz = $argz[1:-1] - var num = (count $argz) - if (== $num 0) { - # list all subcommands - find $_asdf:asdf_dir'/lib/commands' -name 'command-*' | each [cmd]{ - put (re:replace '.*/command-(.*)\.bash' '${1}' $cmd) - } - put 'plugin' - put 'list' - } else { - if (match $argz 'current') { - # asdf current - _asdf:asdf plugin-list - } elif (match $argz 'env') { - # asdf env - ls-shims - } elif (match-nested $argz 'env' '*') { - # asdf env [util] - ls-executables - } elif (match $argz 'exec') { - # asdf exec - ls-shims - } elif (match $argz 'global') { - # asdf global - _asdf:asdf plugin-list - } elif (match-nested $argz 'global' '*') { - # asdf global - ls-installed-versions $argz[-1] - } elif (match $argz 'install') { - # asdf install - _asdf:asdf plugin-list - } elif (match-nested $argz 'install' '*') { - # asdf install - ls-all-versions $argz[-1] - } elif (match $argz 'latest') { - # asdf latest - _asdf:asdf plugin-list - } elif (match-nested $argz 'latest' '*') { - # asdf latest [] - ls-all-versions $argz[-1] - } elif (match $argz 'list-all') { - # asdf list all - _asdf:asdf plugin-list - } elif (match-nested $argz 'list-all' '*') { - # asdf list all [] - ls-all-versions $argz[-1] - } elif (match $argz 'list') { - # asdf list - _asdf:asdf plugin-list - } elif (match-nested $argz 'list' '*') { - # asdf list [] - ls-installed-versions $argz[-1] - } elif (match $argz 'local') { - # asdf local - _asdf:asdf plugin-list - } elif (match-nested $argz 'local' '*') { - # asdf local [] - ls-installed-versions $argz[-1] - } elif (match $argz 'plugin-add') { - # asdf plugin add - _asdf:asdf plugin-list-all | each [line]{ - put (re:replace '([^\s]+)\s+.*' '${1}' $line) - } - } elif (match $argz 'plugin-list') { - # asdf plugin list - put '--urls' - put '--refs' - put 'all' - } elif (match $argz 'plugin-push') { - # asdf plugin push - _asdf:asdf plugin-list - } elif (match $argz 'plugin-remove') { - # asdf plugin remove - _asdf:asdf plugin-list - } elif (match $argz 'plugin-update') { - # asdf plugin update - _asdf:asdf plugin-list - put '--all' - } elif (match $argz 'plugin') { - # list plugin-* subcommands - find $_asdf:asdf_dir'/lib/commands' -name 'command-plugin-*' | each [cmd]{ - put (re:replace '.*/command-plugin-(.*)\.bash' '${1}' $cmd) - } - } elif (match $argz 'reshim') { - # asdf reshim - _asdf:asdf plugin-list - } elif (match-nested $argz 'reshim' '*') { - # asdf reshim - ls-installed-versions $argz[-1] - } elif (match $argz 'shim-versions') { - # asdf shim-versions - ls-shims - } elif (match $argz 'uninstall') { - # asdf uninstall - _asdf:asdf plugin-list - } elif (match-nested $argz 'uninstall' '*') { - # asdf uninstall - ls-installed-versions $argz[-1] - } elif (match $argz 'update') { - if (== $num 1) { - # asdf update - put '--head' - } - } elif (match $argz 'where') { - # asdf where - _asdf:asdf plugin-list - } elif (match-nested $argz 'where' '*') { - # asdf where [] - ls-installed-versions $argz[-1] - } elif (match $argz 'which') { - ls-shims - } - } -} diff --git a/docs/guide/getting-started.md b/docs/guide/getting-started.md index ef761f925..226a31c00 100644 --- a/docs/guide/getting-started.md +++ b/docs/guide/getting-started.md @@ -147,11 +147,12 @@ Completions are automatically configured on installation by the AUR package. Add `asdf.elv` to your `~/.elvish/rc.elv` with: ```shell:no-line-numbers -mkdir -p ~/.elvish/lib -ln -s ~/.asdf/asdf.elv ~/.elvish/lib/asdf.elv +mkdir -p ~/.elvish/lib; ln -s ~/.asdf/asdf.elv ~/.elvish/lib/asdf.elv echo "\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}" >> ~/.elvish/rc.elv ``` +Completions are automatically configured. + ::: ::: details Elvish & Homebrew @@ -159,11 +160,11 @@ echo "\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}" >> ~/.elvish/rc.elv Add `asdf.elv` to your `~/.elvish/rc.elv` with: ```shell:no-line-numbers -mkdir -p ~/.elvish/lib -ln -s (brew --prefix asdf)/libexec/asdf.elv ~/.elvish/lib/asdf.elv +mkdir -p ~/.elvish/lib; ln -s (brew --prefix asdf)/libexec/asdf.elv ~/.elvish/lib/asdf.elv echo "\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}" >> ~/.elvish/rc.elv ``` +Completions are automatically configured. ::: ::: details Elvish & Pacman @@ -171,11 +172,11 @@ echo "\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}" >> ~/.elvish/rc.elv Add `asdf.elv` to your `~/.elvish/rc.elv` with: ```shell:no-line-numbers -mkdir -p ~/.elvish/lib -ln -s /opt/asdf-vm/asdf.elv ~/.elvish/lib/asdf.elv +mkdir -p ~/.elvish/lib; ln -s /opt/asdf-vm/asdf.elv ~/.elvish/lib/asdf.elv echo "\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}" >> ~/.elvish/rc.elv ``` +Completions are automatically configured. ::: ::: details ZSH & Git diff --git a/docs/pt-br/guide/getting-started.md b/docs/pt-br/guide/getting-started.md index 7efc9b705..515c43dff 100644 --- a/docs/pt-br/guide/getting-started.md +++ b/docs/pt-br/guide/getting-started.md @@ -144,6 +144,43 @@ source /opt/asdf-vm/asdf.fish Completions are automatically configured on installation by the AUR package. ::: +::: details Elvish & Git + +Add `asdf.elv` to your `~/.elvish/rc.elv` with: + +```shell:no-line-numbers +mkdir -p ~/.elvish/lib; ln -s ~/.asdf/asdf.elv ~/.elvish/lib/asdf.elv +echo "\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}" >> ~/.elvish/rc.elv +``` + +Completions are automatically configured. + +::: + +::: details Elvish & Homebrew + +Add `asdf.elv` to your `~/.elvish/rc.elv` with: + +```shell:no-line-numbers +mkdir -p ~/.elvish/lib; ln -s (brew --prefix asdf)/libexec/asdf.elv ~/.elvish/lib/asdf.elv +echo "\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}" >> ~/.elvish/rc.elv +``` + +Completions are automatically configured. +::: + +::: details Elvish & Pacman + +Add `asdf.elv` to your `~/.elvish/rc.elv` with: + +```shell:no-line-numbers +mkdir -p ~/.elvish/lib; ln -s /opt/asdf-vm/asdf.elv ~/.elvish/lib/asdf.elv +echo "\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}" >> ~/.elvish/rc.elv +``` + +Completions are automatically configured. +::: + ::: details ZSH & Git Add the following to `~/.zshrc`: diff --git a/docs/pt-br/learn-more/faq.md b/docs/pt-br/learn-more/faq.md index 6847c52bc..df4d0e4d4 100644 --- a/docs/pt-br/learn-more/faq.md +++ b/docs/pt-br/learn-more/faq.md @@ -1,4 +1,4 @@ -# PERGUNTAS FREQUENTES +# Perguntas frequentes Aqui estão algumas perguntas comuns sobre `asdf`. From 1295224c417b73291f6a92f33b2430070b420fe5 Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 17:24:53 -0500 Subject: [PATCH 22/34] Fix uninstall instructions --- docs/manage/core.md | 10 +++++----- docs/pt-br/manage/core.md | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/manage/core.md b/docs/manage/core.md index c8c06e6fa..d3d70fbc6 100644 --- a/docs/manage/core.md +++ b/docs/manage/core.md @@ -268,13 +268,13 @@ use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} and uninstall the `asdf` module with this command: ```shell:no-line-numbers -rm -rf ~/.elvish/lib/asdf.elv +rm -f ~/.elvish/lib/asdf.elv ``` 2. Remove the `$HOME/.asdf` dir: ```shell:no-line-numbers -if (!=s $E:ASDF_DATA_DIR "") { rm -rf $ASDF_DATA_DIR"/.asdf" } else { rm -rf ~/.asdf } +if (!=s $E:ASDF_DATA_DIR "") { rm -rf $E:ASDF_DATA_DIR } else { rm -rf ~/.asdf } ``` 3. Run this command to remove all `asdf` config files: @@ -296,7 +296,7 @@ use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} and uninstall the `asdf` module with this command: ```shell:no-line-numbers -rm -rf ~/.elvish/lib/asdf.elv +rm -f ~/.elvish/lib/asdf.elv ``` 2. Uninstall with your package manager: @@ -324,7 +324,7 @@ use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} and uninstall the `asdf` module with this command: ```shell:no-line-numbers -rm -rf ~/.elvish/lib/asdf.elv +rm -f ~/.elvish/lib/asdf.elv ``` 2. Uninstall with your package manager: @@ -336,7 +336,7 @@ pacman -Rs asdf-vm 3. Remove the `$HOME/.asdf` dir: ```shell:no-line-numbers -if (!=s $E:ASDF_DATA_DIR "") { rm -rf $ASDF_DATA_DIR"/.asdf" } else { rm -rf ~/.asdf } +if (!=s $E:ASDF_DATA_DIR "") { rm -rf $E:ASDF_DATA_DIR } else { rm -rf ~/.asdf } ``` 4. Run this command to remove all `asdf` config files: diff --git a/docs/pt-br/manage/core.md b/docs/pt-br/manage/core.md index 6a36ebf69..a56ae5459 100644 --- a/docs/pt-br/manage/core.md +++ b/docs/pt-br/manage/core.md @@ -270,13 +270,13 @@ use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} e desinstale o módulo `asdf` com este comando: ```shell:no-line-numbers -rm -rf ~/.elvish/lib/asdf.elv +rm -f ~/.elvish/lib/asdf.elv ``` 2. Remova o diretório `$HOME/.asdf`: ```shell:no-line-numbers -if (!=s $E:ASDF_DATA_DIR "") { rm -rf $ASDF_DATA_DIR"/.asdf" } else { rm -rf ~/.asdf } +if (!=s $E:ASDF_DATA_DIR "") { rm -rf $E:ASDF_DATA_DIR } else { rm -rf ~/.asdf } ``` 3. Execute este comando para remover todos os arquivos de configuração `asdf`: @@ -298,7 +298,7 @@ use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} e desinstale o módulo `asdf` com este comando: ```shell:no-line-numbers -rm -rf ~/.elvish/lib/asdf.elv +rm -f ~/.elvish/lib/asdf.elv ``` 2. Desinstale com seu gerenciador de pacotes: @@ -326,7 +326,7 @@ use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} e desinstale o módulo `asdf` com este comando: ```shell:no-line-numbers -rm -rf ~/.elvish/lib/asdf.elv +rm -f ~/.elvish/lib/asdf.elv ``` 2. Desinstale com seu gerenciador de pacotes: @@ -338,7 +338,7 @@ pacman -Rs asdf-vm 3. Remova o diretório `$ HOME/.asdf`: ```shell:no-line-numbers -if (!=s $E:ASDF_DATA_DIR "") { rm -rf $ASDF_DATA_DIR"/.asdf" } else { rm -rf ~/.asdf } +if (!=s $E:ASDF_DATA_DIR "") { rm -rf $E:ASDF_DATA_DIR } else { rm -rf ~/.asdf } ``` 4. Execute este comando para remover todos os arquivos de configuração `asdf`: From 84f073aa5cd0c73cad1ee81115668f43c76632cb Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 17:25:42 -0500 Subject: [PATCH 23/34] Cleanup debug code --- asdf.elv | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/asdf.elv b/asdf.elv index a70c8e18e..10fb9990a 100644 --- a/asdf.elv +++ b/asdf.elv @@ -32,22 +32,17 @@ fn asdf [command @args]{ } fn match [argz name]{ - try { - var num = (count $argz) - if (== $num 0) { - ==s $name '' - } elif (==s $name $argz[0]) { - == $num 1 - } else { - ==s $name (str:join '-' $argz) - } - } except err { - echo '$err' + var num = (count $argz) + if (== $num 0) { + ==s $name '' + } elif (==s $name $argz[0]) { + == $num 1 + } else { + ==s $name (str:join '-' $argz) } } fn match-nested [argz name @pattern]{ - try { var num_pat = (count $pattern) var i = 0 var matched = $true @@ -66,9 +61,6 @@ fn match-nested [argz name @pattern]{ matched = $false } put $matched - } except err { - echo '$err' - } } fn ls-shims []{ From 2c9529bf7aff747ed70cf6a873c923d702e751df Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 17:26:42 -0500 Subject: [PATCH 24/34] Comments --- asdf.elv | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/asdf.elv b/asdf.elv index 10fb9990a..e8e603b74 100644 --- a/asdf.elv +++ b/asdf.elv @@ -75,9 +75,13 @@ fn ls-executables []{ if (test -x $p) { path:base $p } - } except { } + } except { + # don't fail if permission denied + } } - } except { } + } except { + # silence default non-zero exit status + } } fn ls-installed-versions [plugin_name]{ From f871425ba8958f0cbca54e5a613653382a92d83b Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 18:07:03 -0500 Subject: [PATCH 25/34] Fix completer in unit tests --- asdf.elv | 2 +- docs/guide/getting-started.md | 9 ++++++--- docs/manage/core.md | 9 ++++++--- docs/pt-br/guide/getting-started.md | 9 ++++++--- docs/pt-br/manage/core.md | 9 ++++++--- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/asdf.elv b/asdf.elv index e8e603b74..8eed25a5d 100644 --- a/asdf.elv +++ b/asdf.elv @@ -110,7 +110,7 @@ for path [ } # Setup argument completions -set edit:completion:arg-completer[asdf] = [@argz]{ +fn arg-completer [@argz]{ argz = $argz[1:-1] # strip 'asdf' and trailing empty string var num = (count $argz) if (== $num 0) { diff --git a/docs/guide/getting-started.md b/docs/guide/getting-started.md index 226a31c00..648490bd8 100644 --- a/docs/guide/getting-started.md +++ b/docs/guide/getting-started.md @@ -148,7 +148,8 @@ Add `asdf.elv` to your `~/.elvish/rc.elv` with: ```shell:no-line-numbers mkdir -p ~/.elvish/lib; ln -s ~/.asdf/asdf.elv ~/.elvish/lib/asdf.elv -echo "\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}" >> ~/.elvish/rc.elv +echo '\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv +echo '\nedit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv ``` Completions are automatically configured. @@ -161,7 +162,8 @@ Add `asdf.elv` to your `~/.elvish/rc.elv` with: ```shell:no-line-numbers mkdir -p ~/.elvish/lib; ln -s (brew --prefix asdf)/libexec/asdf.elv ~/.elvish/lib/asdf.elv -echo "\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}" >> ~/.elvish/rc.elv +echo '\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv +echo '\nedit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv ``` Completions are automatically configured. @@ -173,7 +175,8 @@ Add `asdf.elv` to your `~/.elvish/rc.elv` with: ```shell:no-line-numbers mkdir -p ~/.elvish/lib; ln -s /opt/asdf-vm/asdf.elv ~/.elvish/lib/asdf.elv -echo "\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}" >> ~/.elvish/rc.elv +echo '\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv +echo '\nedit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv ``` Completions are automatically configured. diff --git a/docs/manage/core.md b/docs/manage/core.md index d3d70fbc6..cd0059858 100644 --- a/docs/manage/core.md +++ b/docs/manage/core.md @@ -259,10 +259,11 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc ::: details Elvish & Git -1. In your `~/.elvish/rc.elv` remove the line that imports the `asdf` module: +1. In your `~/.elvish/rc.elv` remove the lines that use the `asdf` module: ```shell use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} +edit:completion:arg-completer[asdf] = $_asdf:arg-completer~ ``` and uninstall the `asdf` module with this command: @@ -287,10 +288,11 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc ::: details Elvish & Homebrew -1. In your `~/.elvish/rc.elv` remove the line that imports the `asdf` module: +1. In your `~/.elvish/rc.elv` remove the lines that use the `asdf` module: ```shell use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} +edit:completion:arg-completer[asdf] = $_asdf:arg-completer~ ``` and uninstall the `asdf` module with this command: @@ -315,10 +317,11 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc ::: details Elvish & Pacman -1. In your `~/.elvish/rc.elv` remove the line that imports the `asdf` module: +1. In your `~/.elvish/rc.elv` remove the lines that use the `asdf` module: ```shell use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} +edit:completion:arg-completer[asdf] = $_asdf:arg-completer~ ``` and uninstall the `asdf` module with this command: diff --git a/docs/pt-br/guide/getting-started.md b/docs/pt-br/guide/getting-started.md index 515c43dff..c43092e9d 100644 --- a/docs/pt-br/guide/getting-started.md +++ b/docs/pt-br/guide/getting-started.md @@ -150,7 +150,8 @@ Add `asdf.elv` to your `~/.elvish/rc.elv` with: ```shell:no-line-numbers mkdir -p ~/.elvish/lib; ln -s ~/.asdf/asdf.elv ~/.elvish/lib/asdf.elv -echo "\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}" >> ~/.elvish/rc.elv +echo '\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv +echo '\nedit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv ``` Completions are automatically configured. @@ -163,7 +164,8 @@ Add `asdf.elv` to your `~/.elvish/rc.elv` with: ```shell:no-line-numbers mkdir -p ~/.elvish/lib; ln -s (brew --prefix asdf)/libexec/asdf.elv ~/.elvish/lib/asdf.elv -echo "\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}" >> ~/.elvish/rc.elv +echo '\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv +echo '\nedit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv ``` Completions are automatically configured. @@ -175,7 +177,8 @@ Add `asdf.elv` to your `~/.elvish/rc.elv` with: ```shell:no-line-numbers mkdir -p ~/.elvish/lib; ln -s /opt/asdf-vm/asdf.elv ~/.elvish/lib/asdf.elv -echo "\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}" >> ~/.elvish/rc.elv +echo '\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv +echo '\nedit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv ``` Completions are automatically configured. diff --git a/docs/pt-br/manage/core.md b/docs/pt-br/manage/core.md index a56ae5459..39d444bd0 100644 --- a/docs/pt-br/manage/core.md +++ b/docs/pt-br/manage/core.md @@ -261,10 +261,11 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc ::: details Elvish & Git -1. Em seu `~/.elvish/rc.elv` remova a linha que importa o módulo `asdf`: +1. Em seu `~/.elvish/rc.elv` remova as linhas que importa o módulo `asdf`: ```shell use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} +edit:completion:arg-completer[asdf] = $_asdf:arg-completer~ ``` e desinstale o módulo `asdf` com este comando: @@ -289,10 +290,11 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc ::: details Elvish & Homebrew -1. Em seu `~/.elvish/rc.elv` remova a linha que importa o módulo `asdf`: +1. Em seu `~/.elvish/rc.elv` remova as linhas que importa o módulo `asdf`: ```shell use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} +edit:completion:arg-completer[asdf] = $_asdf:arg-completer~ ``` e desinstale o módulo `asdf` com este comando: @@ -317,10 +319,11 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc ::: details Elvish & Pacman -1. Em seu `~/.elvish/rc.elv` remova a linha que importa o módulo `asdf`: +1. Em seu `~/.elvish/rc.elv` remova as linhas que importa o módulo `asdf`: ```shell use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} +edit:completion:arg-completer[asdf] = $_asdf:arg-completer~ ``` e desinstale o módulo `asdf` com este comando: From fa841236db34bca9d64b27f33342519b9325d449 Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 18:07:13 -0500 Subject: [PATCH 26/34] Add unit test for ASDF_DATA_DIR --- test/asdf_elvish.bats | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/asdf_elvish.bats b/test/asdf_elvish.bats index 22ec863f8..b585ef3cc 100644 --- a/test/asdf_elvish.bats +++ b/test/asdf_elvish.bats @@ -38,6 +38,17 @@ cleaned_path() { [ "$output" = "/path/to/asdf" ] } +@test "retains ASDF_DATA_DIR" { + output=$(elvish -norc -c " + set-env ASDF_DATA_DIR "/path/to/asdf-data" + paths = [$(cleaned_path)] + use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} + echo \$E:ASDF_DATA_DIR + ") + [ "$?" -eq 0 ] + [ "$output" = "/path/to/asdf-data" ] +} + @test "adds asdf dirs to PATH" { result=$(elvish -norc -c " unset-env ASDF_DIR From 9036d9123e4b6103e6ce8fd54095f816a534adc1 Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 18:14:06 -0500 Subject: [PATCH 27/34] Revert change in command-info.bash --- lib/commands/command-info.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/commands/command-info.bash b/lib/commands/command-info.bash index 025cd7bfd..2c6c3fc80 100644 --- a/lib/commands/command-info.bash +++ b/lib/commands/command-info.bash @@ -5,7 +5,7 @@ info_command() { printf "%s:\\n%s\\n\\n" "SHELL" "$($SHELL --version)" printf "%s:\\n%s\\n\\n" "ASDF VERSION" "$(asdf_version)" printf "%s:\\n%s\\n\\n" "ASDF ENVIRONMENT VARIABLES" "$(env | grep -E "ASDF_DIR|ASDF_DATA_DIR|ASDF_CONFIG_FILE|ASDF_DEFAULT_TOOL_VERSIONS_FILENAME")" - printf "%s:\\n%s\\n\\n" "ASDF INSTALLED PLUGINS" "$("$ASDF_DIR/bin/asdf" plugin list --urls --refs)" + printf "%s:\\n%s\\n\\n" "ASDF INSTALLED PLUGINS" "$(asdf plugin list --urls --refs)" } info_command "$@" From ab495ffe03e5afc01905aa3f4f943e202a5efae6 Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 18:24:28 -0500 Subject: [PATCH 28/34] Fix installation instructions --- docs/guide/getting-started.md | 12 ++++++------ docs/pt-br/guide/getting-started.md | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/guide/getting-started.md b/docs/guide/getting-started.md index 648490bd8..03834c7af 100644 --- a/docs/guide/getting-started.md +++ b/docs/guide/getting-started.md @@ -148,8 +148,8 @@ Add `asdf.elv` to your `~/.elvish/rc.elv` with: ```shell:no-line-numbers mkdir -p ~/.elvish/lib; ln -s ~/.asdf/asdf.elv ~/.elvish/lib/asdf.elv -echo '\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv -echo '\nedit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv +echo "\n"'use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv +echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv ``` Completions are automatically configured. @@ -162,8 +162,8 @@ Add `asdf.elv` to your `~/.elvish/rc.elv` with: ```shell:no-line-numbers mkdir -p ~/.elvish/lib; ln -s (brew --prefix asdf)/libexec/asdf.elv ~/.elvish/lib/asdf.elv -echo '\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv -echo '\nedit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv +echo "\n"'use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv +echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv ``` Completions are automatically configured. @@ -175,8 +175,8 @@ Add `asdf.elv` to your `~/.elvish/rc.elv` with: ```shell:no-line-numbers mkdir -p ~/.elvish/lib; ln -s /opt/asdf-vm/asdf.elv ~/.elvish/lib/asdf.elv -echo '\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv -echo '\nedit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv +echo "\n"'use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv +echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv ``` Completions are automatically configured. diff --git a/docs/pt-br/guide/getting-started.md b/docs/pt-br/guide/getting-started.md index c43092e9d..3ea8418ca 100644 --- a/docs/pt-br/guide/getting-started.md +++ b/docs/pt-br/guide/getting-started.md @@ -150,8 +150,8 @@ Add `asdf.elv` to your `~/.elvish/rc.elv` with: ```shell:no-line-numbers mkdir -p ~/.elvish/lib; ln -s ~/.asdf/asdf.elv ~/.elvish/lib/asdf.elv -echo '\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv -echo '\nedit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv +echo "\n"'use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv +echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv ``` Completions are automatically configured. @@ -164,8 +164,8 @@ Add `asdf.elv` to your `~/.elvish/rc.elv` with: ```shell:no-line-numbers mkdir -p ~/.elvish/lib; ln -s (brew --prefix asdf)/libexec/asdf.elv ~/.elvish/lib/asdf.elv -echo '\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv -echo '\nedit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv +echo "\n"'use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv +echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv ``` Completions are automatically configured. @@ -177,8 +177,8 @@ Add `asdf.elv` to your `~/.elvish/rc.elv` with: ```shell:no-line-numbers mkdir -p ~/.elvish/lib; ln -s /opt/asdf-vm/asdf.elv ~/.elvish/lib/asdf.elv -echo '\nuse asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv -echo '\nedit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv +echo "\n"'use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args}' >> ~/.elvish/rc.elv +echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv ``` Completions are automatically configured. From 0b006ed6b427e83f46a420d3646bd830d6ad25c8 Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 20:45:34 -0500 Subject: [PATCH 29/34] Add flags --- asdf.elv | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/asdf.elv b/asdf.elv index 8eed25a5d..44d48127e 100644 --- a/asdf.elv +++ b/asdf.elv @@ -42,23 +42,18 @@ fn match [argz name]{ } } -fn match-nested [argz name @pattern]{ - var num_pat = (count $pattern) - var i = 0 - var matched = $true - if (match $argz[:(- 0 $num_pat)] $name) { - var nested = $argz[(- 0 $num_pat):] - if (== (count $nested) (count $pattern)) { - for pat [$@pattern] { - if (and (!=s $pat '*') (==s $pat $nested[$i])) { - matched = $false - break - } - i = (+ $i 1) +fn match-nested [argz @pattern]{ + var matched = $true; + if (!= (count $argz) (count $pattern)) { + matched = $false + } else { + for i [(range (count $pattern))] { + chunk = $pattern[$i] + if (and (!=s $chunk '*') (!=s $chunk $argz[$i])) { + matched = $false + break } } - } else { - matched = $false } put $matched } @@ -145,6 +140,9 @@ fn arg-completer [@argz]{ } elif (match-nested $argz 'install' '*') { # asdf install ls-all-versions $argz[-1] + } elif (match-nested $argz 'install' '*' '*') { + # asdf install [--keep-download] + put '--keep-download' } elif (match $argz 'latest') { # asdf latest asdf plugin-list @@ -164,11 +162,14 @@ fn arg-completer [@argz]{ # asdf list [] ls-installed-versions $argz[-1] } elif (match $argz 'local') { - # asdf local + # asdf local [-p] [--parent] asdf plugin-list } elif (match-nested $argz 'local' '*') { + # asdf local [] [-p] [--parent] # asdf local [] ls-installed-versions $argz[-1] + put '-p' + put '--parent' } elif (match $argz 'plugin-add') { # asdf plugin add asdf plugin-list-all | each [line]{ From 4383fbedc6df0ed047f45305b0b504fd3c0fe44f Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 20:45:40 -0500 Subject: [PATCH 30/34] Ignore downloads dir --- .gitignore | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index fcf49ff2a..69ca2959d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ -installs +/installs +/downloads /plugins -shims +/shims repository .vagrant keyrings From 624949c6754b9d78e142e413e08f20120a11e615 Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 21:28:01 -0500 Subject: [PATCH 31/34] Use regex for matching --- asdf.elv | 58 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/asdf.elv b/asdf.elv index 44d48127e..2d8118b46 100644 --- a/asdf.elv +++ b/asdf.elv @@ -42,14 +42,15 @@ fn match [argz name]{ } } -fn match-nested [argz @pattern]{ +fn match-pats [argz @pats]{ var matched = $true; - if (!= (count $argz) (count $pattern)) { + if (!= (count $argz) (count $pats)) { matched = $false } else { - for i [(range (count $pattern))] { - chunk = $pattern[$i] - if (and (!=s $chunk '*') (!=s $chunk $argz[$i])) { + for i [(range (count $pats))] { + pat = '^'$pats[$i]'$' + arg = $argz[$i] + if (not (re:match $pat $arg)) { matched = $false break } @@ -81,13 +82,13 @@ fn ls-executables []{ fn ls-installed-versions [plugin_name]{ asdf list $plugin_name | each [version]{ - put (re:replace '^\s*(.*)\s*' '${1}' $version) + put (re:replace '\s*(.*)\s*' '${1}' $version) } } fn ls-all-versions [plugin_name]{ asdf list-all $plugin_name | each [version]{ - put (re:replace '^\s*(.*)\s*' '${1}' $version) + put (re:replace '\s*(.*)\s*' '${1}' $version) } } @@ -122,7 +123,7 @@ fn arg-completer [@argz]{ } elif (match $argz 'env') { # asdf env ls-shims - } elif (match-nested $argz 'env' '*') { + } elif (match-pats $argz 'env' '.*') { # asdf env [util] ls-executables } elif (match $argz 'exec') { @@ -131,43 +132,58 @@ fn arg-completer [@argz]{ } elif (match $argz 'global') { # asdf global asdf plugin-list - } elif (match-nested $argz 'global' '*') { + } elif (match-pats $argz 'global' '.*') { # asdf global ls-installed-versions $argz[-1] } elif (match $argz 'install') { # asdf install asdf plugin-list - } elif (match-nested $argz 'install' '*') { + } elif (match-pats $argz 'install' '.*') { # asdf install ls-all-versions $argz[-1] - } elif (match-nested $argz 'install' '*' '*') { + } elif (match-pats $argz 'install' '.*' '.*') { # asdf install [--keep-download] put '--keep-download' } elif (match $argz 'latest') { # asdf latest asdf plugin-list - } elif (match-nested $argz 'latest' '*') { + } elif (match-pats $argz 'latest' '.*') { # asdf latest [] ls-all-versions $argz[-1] } elif (match $argz 'list-all') { # asdf list all asdf plugin-list - } elif (match-nested $argz 'list-all' '*') { + } elif (match-pats $argz 'list-all' '.*') { # asdf list all [] ls-all-versions $argz[-1] } elif (match $argz 'list') { # asdf list asdf plugin-list - } elif (match-nested $argz 'list' '*') { + } elif (match-pats $argz 'list' '.*') { # asdf list [] ls-installed-versions $argz[-1] } elif (match $argz 'local') { - # asdf local [-p] [--parent] + # asdf local [-p|--parent] asdf plugin-list - } elif (match-nested $argz 'local' '*') { - # asdf local [] [-p] [--parent] - # asdf local [] + put '-p' + put '--parent' + } elif (match-pats $argz 'local' '(-p|(--parent))') { + # asdf local [-p|--parent] + asdf plugin-list + } elif (match-pats $argz 'local' '.*') { + # asdf local [-p|--parent] + # asdf local + ls-installed-versions $argz[-1] + put '-p' + put '--parent' + } elif (match-pats $argz 'local' '(-p|(--parent))' '.*') { + # asdf local [-p|--parent] ls-installed-versions $argz[-1] + } elif (match-pats $argz 'local' '.*' '(-p|(--parent))') { + # asdf local [-p|--parent] + ls-installed-versions $argz[-2] + } elif (match-pats $argz 'local' '.*' '.*') { + # asdf local [-p|--parent] put '-p' put '--parent' } elif (match $argz 'plugin-add') { @@ -198,7 +214,7 @@ fn arg-completer [@argz]{ } elif (match $argz 'reshim') { # asdf reshim asdf plugin-list - } elif (match-nested $argz 'reshim' '*') { + } elif (match-pats $argz 'reshim' '.*') { # asdf reshim ls-installed-versions $argz[-1] } elif (match $argz 'shim-versions') { @@ -207,7 +223,7 @@ fn arg-completer [@argz]{ } elif (match $argz 'uninstall') { # asdf uninstall asdf plugin-list - } elif (match-nested $argz 'uninstall' '*') { + } elif (match-pats $argz 'uninstall' '.*') { # asdf uninstall ls-installed-versions $argz[-1] } elif (match $argz 'update') { @@ -218,7 +234,7 @@ fn arg-completer [@argz]{ } elif (match $argz 'where') { # asdf where asdf plugin-list - } elif (match-nested $argz 'where' '*') { + } elif (match-pats $argz 'where' '.*') { # asdf where [] ls-installed-versions $argz[-1] } elif (match $argz 'which') { From 0b41485d52c0db6ad3588e95a188034491e7102b Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 9 Oct 2021 22:10:47 -0500 Subject: [PATCH 32/34] Add plugin-test completion --- asdf.elv | 66 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/asdf.elv b/asdf.elv index 2d8118b46..3abb20359 100644 --- a/asdf.elv +++ b/asdf.elv @@ -31,18 +31,7 @@ fn asdf [command @args]{ } } -fn match [argz name]{ - var num = (count $argz) - if (== $num 0) { - ==s $name '' - } elif (==s $name $argz[0]) { - == $num 1 - } else { - ==s $name (str:join '-' $argz) - } -} - -fn match-pats [argz @pats]{ +fn match [argz @pats]{ var matched = $true; if (!= (count $argz) (count $pats)) { matched = $false @@ -115,7 +104,6 @@ fn arg-completer [@argz]{ put (re:replace '.*/command-(.*)\.bash' '${1}' $cmd) } put 'plugin' - put 'list' } else { if (match $argz 'current') { # asdf current @@ -123,7 +111,7 @@ fn arg-completer [@argz]{ } elif (match $argz 'env') { # asdf env ls-shims - } elif (match-pats $argz 'env' '.*') { + } elif (match $argz 'env' '.*') { # asdf env [util] ls-executables } elif (match $argz 'exec') { @@ -132,34 +120,34 @@ fn arg-completer [@argz]{ } elif (match $argz 'global') { # asdf global asdf plugin-list - } elif (match-pats $argz 'global' '.*') { + } elif (match $argz 'global' '.*') { # asdf global ls-installed-versions $argz[-1] } elif (match $argz 'install') { # asdf install asdf plugin-list - } elif (match-pats $argz 'install' '.*') { + } elif (match $argz 'install' '.*') { # asdf install ls-all-versions $argz[-1] - } elif (match-pats $argz 'install' '.*' '.*') { + } elif (match $argz 'install' '.*' '.*') { # asdf install [--keep-download] put '--keep-download' } elif (match $argz 'latest') { # asdf latest asdf plugin-list - } elif (match-pats $argz 'latest' '.*') { + } elif (match $argz 'latest' '.*') { # asdf latest [] ls-all-versions $argz[-1] } elif (match $argz 'list-all') { # asdf list all asdf plugin-list - } elif (match-pats $argz 'list-all' '.*') { + } elif (match $argz 'list-all' '.*') { # asdf list all [] ls-all-versions $argz[-1] } elif (match $argz 'list') { # asdf list asdf plugin-list - } elif (match-pats $argz 'list' '.*') { + } elif (match $argz 'list' '.*') { # asdf list [] ls-installed-versions $argz[-1] } elif (match $argz 'local') { @@ -167,42 +155,54 @@ fn arg-completer [@argz]{ asdf plugin-list put '-p' put '--parent' - } elif (match-pats $argz 'local' '(-p|(--parent))') { + } elif (match $argz 'local' '(-p|(--parent))') { # asdf local [-p|--parent] asdf plugin-list - } elif (match-pats $argz 'local' '.*') { + } elif (match $argz 'local' '.*') { # asdf local [-p|--parent] # asdf local ls-installed-versions $argz[-1] put '-p' put '--parent' - } elif (match-pats $argz 'local' '(-p|(--parent))' '.*') { + } elif (match $argz 'local' '(-p|(--parent))' '.*') { # asdf local [-p|--parent] ls-installed-versions $argz[-1] - } elif (match-pats $argz 'local' '.*' '(-p|(--parent))') { + } elif (match $argz 'local' '.*' '(-p|(--parent))') { # asdf local [-p|--parent] ls-installed-versions $argz[-2] - } elif (match-pats $argz 'local' '.*' '.*') { + } elif (match $argz 'local' '.*' '.*') { # asdf local [-p|--parent] put '-p' put '--parent' - } elif (match $argz 'plugin-add') { + } elif (or (match $argz 'plugin-add') (match $argz 'plugin' 'add')) { # asdf plugin add asdf plugin-list-all | each [line]{ put (re:replace '([^\s]+)\s+.*' '${1}' $line) } - } elif (match $argz 'plugin-list') { + } elif (or (match $argz 'plugin-list') (match $argz 'plugin' 'list')) { # asdf plugin list put '--urls' put '--refs' put 'all' - } elif (match $argz 'plugin-push') { + } elif (or (match $argz 'plugin-push') (match $argz 'plugin' 'push')) { # asdf plugin push asdf plugin-list - } elif (match $argz 'plugin-remove') { + } elif (or (match $argz 'plugin-remove') (match $argz 'plugin' 'remove')) { # asdf plugin remove asdf plugin-list - } elif (match $argz 'plugin-update') { + } elif (and (>= (count $argz) 3) (match $argz[:3] 'plugin-test' '.*' '.*')) { + # asdf plugin-test [--asdf-tool-version ] [--asdf-plugin-gitref ] [test-command*] + put '--asdf-plugin-gitref' + put '--asdf-tool-version' + ls-executables + ls-shims + } elif (and (>= (count $argz) 4) (match $argz[:4] 'plugin' 'test' '.*' '.*')) { + # asdf plugin test [--asdf-tool-version ] [--asdf-plugin-gitref ] [test-command*] + put '--asdf-plugin-gitref' + put '--asdf-tool-version' + ls-executables + ls-shims + } elif (or (match $argz 'plugin-update') (match $argz 'plugin' 'update')) { # asdf plugin update asdf plugin-list put '--all' @@ -214,7 +214,7 @@ fn arg-completer [@argz]{ } elif (match $argz 'reshim') { # asdf reshim asdf plugin-list - } elif (match-pats $argz 'reshim' '.*') { + } elif (match $argz 'reshim' '.*') { # asdf reshim ls-installed-versions $argz[-1] } elif (match $argz 'shim-versions') { @@ -223,7 +223,7 @@ fn arg-completer [@argz]{ } elif (match $argz 'uninstall') { # asdf uninstall asdf plugin-list - } elif (match-pats $argz 'uninstall' '.*') { + } elif (match $argz 'uninstall' '.*') { # asdf uninstall ls-installed-versions $argz[-1] } elif (match $argz 'update') { @@ -234,7 +234,7 @@ fn arg-completer [@argz]{ } elif (match $argz 'where') { # asdf where asdf plugin-list - } elif (match-pats $argz 'where' '.*') { + } elif (match $argz 'where' '.*') { # asdf where [] ls-installed-versions $argz[-1] } elif (match $argz 'which') { From e697aaba1d15ea53efbddb31b382a7df0de379bb Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 13 Nov 2021 14:48:02 -0600 Subject: [PATCH 33/34] Format string --- asdf.fish | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/asdf.fish b/asdf.fish index 073bd5f71..854bcf11a 100644 --- a/asdf.fish +++ b/asdf.fish @@ -2,9 +2,9 @@ set -x ASDF_DIR (dirname (status -f)) set -l asdf_user_shims ( if test -n "$ASDF_DATA_DIR" - printf $ASDF_DATA_DIR/shims + printf "%s\n" "$ASDF_DATA_DIR/shims" else - printf $HOME/.asdf/shims + printf "%s\n" "$HOME/.asdf/shims" end ) From 25382798d9b2d65a3867f548732a5f625f195d85 Mon Sep 17 00:00:00 2001 From: Elijah Shaw-Rutschman Date: Sat, 13 Nov 2021 15:00:09 -0600 Subject: [PATCH 34/34] Download elvish binary --- .github/workflows/tests.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3b4468bee..3ec4a5eb0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -34,15 +34,16 @@ jobs: if: runner.os == 'linux' run: | sudo add-apt-repository -y ppa:fish-shell/nightly-master - sudo add-apt-repository -y ppa:longsleep/golang-backports sudo apt-get update - sudo apt-get -y install fish golang-go - - # Build elvish and add to path - git clone --depth 1 --single-branch https://github.com/elves/elvish - cd elvish - make get - echo "$HOME/go/bin" >>"$GITHUB_PATH" + sudo apt-get -y install fish curl + + # Download elvish binary and add to path + curl https://dl.elv.sh/linux-amd64/elvish-v0.16.3.tar.gz -o elvish-v0.16.3.tar.gz + tar xzf elvish-v0.16.3.tar.gz + rm elvish-v0.16.3.tar.gz + mkdir -p "$HOME/bin" + mv elvish-v0.16.3 "$HOME/bin/elvish" + echo "$HOME/bin" >>"$GITHUB_PATH" - name: Install bats run: |