From 824550ed2009c7e8c4c84afd7a01197d451c47bf Mon Sep 17 00:00:00 2001 From: Bruno Roque Date: Fri, 11 Feb 2022 23:19:55 +0100 Subject: [PATCH] feat: upgrade elvish to 0.17.0 (#1159) * feat: upgrade elvish to 0.17.0 * Remove || and fix array slice * Update elvish config path * Tests use new path * Escape $ in bats * Fix legacy assignment in test --- .github/workflows/tests.yml | 8 ++--- asdf.elv | 48 +++++++++++++-------------- docs/guide/getting-started.md | 24 +++++++------- docs/manage/core.md | 24 +++++++------- docs/pt-br/guide/getting-started.md | 24 +++++++------- docs/pt-br/manage/core.md | 24 +++++++------- docs/zh-hans/guide/getting-started.md | 24 +++++++------- docs/zh-hans/manage/core.md | 18 +++++----- test/asdf_elvish.bats | 34 +++++++++---------- 9 files changed, 114 insertions(+), 114 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3ec4a5eb..84c3e1b4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -38,11 +38,11 @@ jobs: 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 + curl https://dl.elv.sh/linux-amd64/elvish-v0.17.0.tar.gz -o elvish-v0.17.0.tar.gz + tar xzf elvish-v0.17.0.tar.gz + rm elvish-v0.17.0.tar.gz mkdir -p "$HOME/bin" - mv elvish-v0.16.3 "$HOME/bin/elvish" + mv elvish-v0.17.0 "$HOME/bin/elvish" echo "$HOME/bin" >>"$GITHUB_PATH" - name: Install bats diff --git a/asdf.elv b/asdf.elv index 3abb2035..a9376efa 100644 --- a/asdf.elv +++ b/asdf.elv @@ -5,21 +5,21 @@ use path var asdf_dir = $E:HOME'/.asdf' if (and (has-env ASDF_DIR) (!=s $E:ASDF_DIR '')) { - asdf_dir = $E:ASDF_DIR + set asdf_dir = $E:ASDF_DIR } else { set-env ASDF_DIR $asdf_dir } 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 + set asdf_data_dir = $E:ASDF_DATA_DIR } # Add function wrapper so we can export variables -fn asdf [command @args]{ +fn asdf {|command @args| if (==s $command 'shell') { # set environment variables - parts = [($asdf_dir'/bin/asdf' export-shell-version elvish $@args)] + var 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') { @@ -31,16 +31,16 @@ fn asdf [command @args]{ } } -fn match [argz @pats]{ +fn match {|argz @pats| var matched = $true; if (!= (count $argz) (count $pats)) { - matched = $false + set matched = $false } else { for i [(range (count $pats))] { - pat = '^'$pats[$i]'$' - arg = $argz[$i] + var pat = '^'$pats[$i]'$' + var arg = $argz[$i] if (not (re:match $pat $arg)) { - matched = $false + set matched = $false break } } @@ -48,14 +48,14 @@ fn match [argz @pats]{ put $matched } -fn ls-shims []{ +fn ls-shims { ls $asdf_data_dir'/shims' } -fn ls-executables []{ +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]{ + find $@paths '(' -type f -o -type l ')' -print 2>/dev/null | each {|p| try { if (test -x $p) { path:base $p @@ -69,14 +69,14 @@ fn ls-executables []{ } } -fn ls-installed-versions [plugin_name]{ - asdf list $plugin_name | each [version]{ +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]{ +fn ls-all-versions {|plugin_name| + asdf list-all $plugin_name | each {|version| put (re:replace '\s*(.*)\s*' '${1}' $version) } } @@ -87,7 +87,7 @@ for path [ $asdf_data_dir'/shims' ] { if (not (has-value $paths $path)) { - paths = [ + set paths = [ $@paths $path ] @@ -95,12 +95,12 @@ for path [ } # Setup argument completions -fn arg-completer [@argz]{ - argz = $argz[1:-1] # strip 'asdf' and trailing empty string +fn arg-completer {|@argz| + set 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]{ + find $asdf_dir'/lib/commands' -name 'command-*' | each {|cmd| put (re:replace '.*/command-(.*)\.bash' '${1}' $cmd) } put 'plugin' @@ -176,7 +176,7 @@ fn arg-completer [@argz]{ put '--parent' } elif (or (match $argz 'plugin-add') (match $argz 'plugin' 'add')) { # asdf plugin add - asdf plugin-list-all | each [line]{ + asdf plugin-list-all | each {|line| put (re:replace '([^\s]+)\s+.*' '${1}' $line) } } elif (or (match $argz 'plugin-list') (match $argz 'plugin' 'list')) { @@ -190,13 +190,13 @@ fn arg-completer [@argz]{ } elif (or (match $argz 'plugin-remove') (match $argz 'plugin' 'remove')) { # asdf plugin remove asdf plugin-list - } elif (and (>= (count $argz) 3) (match $argz[:3] 'plugin-test' '.*' '.*')) { + } 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' '.*' '.*')) { + } 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' @@ -208,7 +208,7 @@ fn arg-completer [@argz]{ put '--all' } elif (match $argz 'plugin') { # list plugin-* subcommands - find $asdf_dir'/lib/commands' -name 'command-plugin-*' | each [cmd]{ + find $asdf_dir'/lib/commands' -name 'command-plugin-*' | each {|cmd| put (re:replace '.*/command-plugin-(.*)\.bash' '${1}' $cmd) } } elif (match $argz 'reshim') { diff --git a/docs/guide/getting-started.md b/docs/guide/getting-started.md index 021765d0..1b868074 100644 --- a/docs/guide/getting-started.md +++ b/docs/guide/getting-started.md @@ -148,12 +148,12 @@ Completions are automatically configured on installation by the AUR package. ::: details Elvish & Git -Add `asdf.elv` to your `~/.elvish/rc.elv` with: +Add `asdf.elv` to your `~/.config/elvish/rc.elv` with: ```shell:no-line-numbers -mkdir -p ~/.elvish/lib; ln -s ~/.asdf/asdf.elv ~/.elvish/lib/asdf.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 +mkdir -p ~/.config/elvish/lib; ln -s ~/.asdf/asdf.elv ~/.config/elvish/lib/asdf.elv +echo "\n"'use asdf _asdf; var asdf~ = $_asdf:asdf~' >> ~/.config/elvish/rc.elv +echo "\n"'set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.config/elvish/rc.elv ``` Completions are automatically configured. @@ -162,12 +162,12 @@ Completions are automatically configured. ::: details Elvish & Homebrew -Add `asdf.elv` to your `~/.elvish/rc.elv` with: +Add `asdf.elv` to your `~/.config/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 "\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 +mkdir -p ~/.config/elvish/lib; ln -s (brew --prefix asdf)/libexec/asdf.elv ~/.config/elvish/lib/asdf.elv +echo "\n"'use asdf _asdf; var asdf~ = $_asdf:asdf~' >> ~/.config/elvish/rc.elv +echo "\n"'set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.config/elvish/rc.elv ``` Completions are automatically configured. @@ -175,12 +175,12 @@ Completions are automatically configured. ::: details Elvish & Pacman -Add `asdf.elv` to your `~/.elvish/rc.elv` with: +Add `asdf.elv` to your `~/.config/elvish/rc.elv` with: ```shell:no-line-numbers -mkdir -p ~/.elvish/lib; ln -s /opt/asdf-vm/asdf.elv ~/.elvish/lib/asdf.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 +mkdir -p ~/.config/elvish/lib; ln -s /opt/asdf-vm/asdf.elv ~/.config/elvish/lib/asdf.elv +echo "\n"'use asdf _asdf; var asdf~ = $_asdf:asdf~' >> ~/.config/elvish/rc.elv +echo "\n"'set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.config/elvish/rc.elv ``` Completions are automatically configured. diff --git a/docs/manage/core.md b/docs/manage/core.md index bb22cd1a..1976e1e0 100644 --- a/docs/manage/core.md +++ b/docs/manage/core.md @@ -259,17 +259,17 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc ::: details Elvish & Git -1. In your `~/.elvish/rc.elv` remove the lines that use the `asdf` module: +1. In your `~/.config/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~ +use asdf _asdf; var asdf~ = $_asdf:asdf~ +set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~ ``` and uninstall the `asdf` module with this command: ```shell:no-line-numbers -rm -f ~/.elvish/lib/asdf.elv +rm -f ~/.config/elvish/lib/asdf.elv ``` 2. Remove the `$HOME/.asdf` dir: @@ -288,17 +288,17 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc ::: details Elvish & Homebrew -1. In your `~/.elvish/rc.elv` remove the lines that use the `asdf` module: +1. In your `~/.config/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~ +use asdf _asdf; var asdf~ = $_asdf:asdf~ +set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~ ``` and uninstall the `asdf` module with this command: ```shell:no-line-numbers -rm -f ~/.elvish/lib/asdf.elv +rm -f ~/.config/elvish/lib/asdf.elv ``` 2. Uninstall with your package manager: @@ -317,17 +317,17 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc ::: details Elvish & Pacman -1. In your `~/.elvish/rc.elv` remove the lines that use the `asdf` module: +1. In your `~/.config/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~ +use asdf _asdf; var asdf~ = $_asdf:asdf~ +set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~ ``` and uninstall the `asdf` module with this command: ```shell:no-line-numbers -rm -f ~/.elvish/lib/asdf.elv +rm -f ~/.config/elvish/lib/asdf.elv ``` 2. Uninstall with your package manager: diff --git a/docs/pt-br/guide/getting-started.md b/docs/pt-br/guide/getting-started.md index 74b1f42b..9fb7973d 100644 --- a/docs/pt-br/guide/getting-started.md +++ b/docs/pt-br/guide/getting-started.md @@ -148,12 +148,12 @@ O auto completar é configurado automaticamente durante a instalação do pacote ::: details Elvish & Git -Add `asdf.elv` to your `~/.elvish/rc.elv` with: +Add `asdf.elv` to your `~/.config/elvish/rc.elv` with: ```shell:no-line-numbers -mkdir -p ~/.elvish/lib; ln -s ~/.asdf/asdf.elv ~/.elvish/lib/asdf.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 +mkdir -p ~/.config/elvish/lib; ln -s ~/.asdf/asdf.elv ~/.config/elvish/lib/asdf.elv +echo "\n"'use asdf _asdf; var asdf~ = $_asdf:asdf~' >> ~/.config/elvish/rc.elv +echo "\n"'set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.config/elvish/rc.elv ``` Completions are automatically configured. @@ -162,12 +162,12 @@ Completions are automatically configured. ::: details Elvish & Homebrew -Add `asdf.elv` to your `~/.elvish/rc.elv` with: +Add `asdf.elv` to your `~/.config/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 "\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 +mkdir -p ~/.config/elvish/lib; ln -s (brew --prefix asdf)/libexec/asdf.elv ~/.config/elvish/lib/asdf.elv +echo "\n"'use asdf _asdf; var asdf~ = $_asdf:asdf~' >> ~/.config/elvish/rc.elv +echo "\n"'set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.config/elvish/rc.elv ``` Completions are automatically configured. @@ -175,12 +175,12 @@ Completions are automatically configured. ::: details Elvish & Pacman -Add `asdf.elv` to your `~/.elvish/rc.elv` with: +Add `asdf.elv` to your `~/.config/elvish/rc.elv` with: ```shell:no-line-numbers -mkdir -p ~/.elvish/lib; ln -s /opt/asdf-vm/asdf.elv ~/.elvish/lib/asdf.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 +mkdir -p ~/.config/elvish/lib; ln -s /opt/asdf-vm/asdf.elv ~/.config/elvish/lib/asdf.elv +echo "\n"'use asdf _asdf; var asdf~ = $_asdf:asdf~' >> ~/.config/elvish/rc.elv +echo "\n"'set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.config/elvish/rc.elv ``` Completions are automatically configured. diff --git a/docs/pt-br/manage/core.md b/docs/pt-br/manage/core.md index a48a84d1..a94828a8 100644 --- a/docs/pt-br/manage/core.md +++ b/docs/pt-br/manage/core.md @@ -261,17 +261,17 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc ::: details Elvish & Git -1. Em seu `~/.elvish/rc.elv` remova as linhas que importa o módulo `asdf`: +1. Em seu `~/.config/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~ +use asdf _asdf; var asdf~ = $_asdf:asdf~ +set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~ ``` e desinstale o módulo `asdf` com este comando: ```shell:no-line-numbers -rm -f ~/.elvish/lib/asdf.elv +rm -f ~/.config/elvish/lib/asdf.elv ``` 2. Remova o diretório `$HOME/.asdf`: @@ -290,17 +290,17 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc ::: details Elvish & Homebrew -1. Em seu `~/.elvish/rc.elv` remova as linhas que importa o módulo `asdf`: +1. Em seu `~/.config/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~ +use asdf _asdf; var asdf~ = $_asdf:asdf~ +set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~ ``` e desinstale o módulo `asdf` com este comando: ```shell:no-line-numbers -rm -f ~/.elvish/lib/asdf.elv +rm -f ~/.config/elvish/lib/asdf.elv ``` 2. Desinstale com seu gerenciador de pacotes: @@ -319,17 +319,17 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc ::: details Elvish & Pacman -1. Em seu `~/.elvish/rc.elv` remova as linhas que importa o módulo `asdf`: +1. Em seu `~/.config/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~ +use asdf _asdf; var asdf~ = $_asdf:asdf~ +set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~ ``` e desinstale o módulo `asdf` com este comando: ```shell:no-line-numbers -rm -f ~/.elvish/lib/asdf.elv +rm -f ~/.config/elvish/lib/asdf.elv ``` 2. Desinstale com seu gerenciador de pacotes: diff --git a/docs/zh-hans/guide/getting-started.md b/docs/zh-hans/guide/getting-started.md index b1aaae59..b58a141f 100644 --- a/docs/zh-hans/guide/getting-started.md +++ b/docs/zh-hans/guide/getting-started.md @@ -148,12 +148,12 @@ source /opt/asdf-vm/asdf.fish ::: details Elvish & Git -使用以下命令将 `asdf.elv` 加入到 `~/.elvish/rc.elv` 文件中: +使用以下命令将 `asdf.elv` 加入到 `~/.config/elvish/rc.elv` 文件中: ```shell:no-line-numbers -mkdir -p ~/.elvish/lib; ln -s ~/.asdf/asdf.elv ~/.elvish/lib/asdf.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 +mkdir -p ~/.config/elvish/lib; ln -s ~/.asdf/asdf.elv ~/.config/elvish/lib/asdf.elv +echo "\n"'use asdf _asdf; var asdf~ = $_asdf:asdf~' >> ~/.config/elvish/rc.elv +echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.config/elvish/rc.elv ``` 补全功能将会自动配置。 @@ -162,12 +162,12 @@ echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elv ::: details Elvish & Homebrew -使用以下命令将 `asdf.elv` 加入到 `~/.elvish/rc.elv` 文件中: +使用以下命令将 `asdf.elv` 加入到 `~/.config/elvish/rc.elv` 文件中: ```shell:no-line-numbers -mkdir -p ~/.elvish/lib; ln -s (brew --prefix asdf)/libexec/asdf.elv ~/.elvish/lib/asdf.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 +mkdir -p ~/.config/elvish/lib; ln -s (brew --prefix asdf)/libexec/asdf.elv ~/.config/elvish/lib/asdf.elv +echo "\n"'use asdf _asdf; var asdf~ = $_asdf:asdf~' >> ~/.config/elvish/rc.elv +echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.config/elvish/rc.elv ``` 补全功能将会自动配置。 @@ -176,12 +176,12 @@ echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elv ::: details Elvish & Pacman -使用以下命令将 `asdf.elv` 加入到 `~/.elvish/rc.elv` 文件中: +使用以下命令将 `asdf.elv` 加入到 `~/.config/elvish/rc.elv` 文件中: ```shell:no-line-numbers -mkdir -p ~/.elvish/lib; ln -s /opt/asdf-vm/asdf.elv ~/.elvish/lib/asdf.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 +mkdir -p ~/.config/elvish/lib; ln -s /opt/asdf-vm/asdf.elv ~/.config/elvish/lib/asdf.elv +echo "\n"'use asdf _asdf; var asdf~ = $_asdf:asdf~' >> ~/.config/elvish/rc.elv +echo "\n"'edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.config/elvish/rc.elv ``` 补全功能将会自动配置。 diff --git a/docs/zh-hans/manage/core.md b/docs/zh-hans/manage/core.md index 32d1a355..ecaadf98 100644 --- a/docs/zh-hans/manage/core.md +++ b/docs/zh-hans/manage/core.md @@ -259,17 +259,17 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc ::: details Elvish & Git -1. 在 `~/.elvish/rc.elv` 配置文件中移除使用 `asdf` 模块的行: +1. 在 `~/.config/elvish/rc.elv` 配置文件中移除使用 `asdf` 模块的行: ```shell -use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} +use asdf _asdf; var asdf~ = $_asdf:asdf~ edit:completion:arg-completer[asdf] = $_asdf:arg-completer~ ``` 以及使用以下命令卸载 `asdf` 模块: ```shell:no-line-numbers -rm -f ~/.elvish/lib/asdf.elv +rm -f ~/.config/elvish/lib/asdf.elv ``` 2. 移除 `$HOME/.asdf` 目录: @@ -288,17 +288,17 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc ::: details Elvish & Homebrew -1. 在 `~/.elvish/rc.elv` 配置文件中移除使用 `asdf` 模块的行: +1. 在 `~/.config/elvish/rc.elv` 配置文件中移除使用 `asdf` 模块的行: ```shell -use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} +use asdf _asdf; var asdf~ = $_asdf:asdf~ edit:completion:arg-completer[asdf] = $_asdf:arg-completer~ ``` 以及使用以下命令卸载 `asdf` 模块: ```shell:no-line-numbers -rm -f ~/.elvish/lib/asdf.elv +rm -f ~/.config/elvish/lib/asdf.elv ``` 2. 用包管理器卸载: @@ -317,17 +317,17 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc ::: details Elvish & Pacman -1. 在 `~/.elvish/rc.elv` 配置文件中移除使用 `asdf` 模块的行: +1. 在 `~/.config/elvish/rc.elv` 配置文件中移除使用 `asdf` 模块的行: ```shell -use asdf _asdf; fn asdf [@args]{_asdf:asdf $@args} +use asdf _asdf; var asdf~ = $_asdf:asdf~ edit:completion:arg-completer[asdf] = $_asdf:arg-completer~ ``` 以及使用以下命令卸载 `asdf` 模块: ```shell:no-line-numbers -rm -f ~/.elvish/lib/asdf.elv +rm -f ~/.config/elvish/lib/asdf.elv ``` 2. 用包管理器卸载: diff --git a/test/asdf_elvish.bats b/test/asdf_elvish.bats index b585ef3c..d6679a86 100644 --- a/test/asdf_elvish.bats +++ b/test/asdf_elvish.bats @@ -4,12 +4,12 @@ load test_helpers setup() { cd $(dirname "$BATS_TEST_DIRNAME") - mkdir -p $HOME/.elvish/lib - cp ./asdf.elv $HOME/.elvish/lib/asdftest.elv + mkdir -p $HOME/.config/elvish/lib + cp ./asdf.elv $HOME/.config/elvish/lib/asdftest.elv } teardown() { - rm $HOME/.elvish/lib/asdftest.elv + rm $HOME/.config/elvish/lib/asdftest.elv } cleaned_path() { @@ -19,8 +19,8 @@ cleaned_path() { @test "exports ASDF_DIR" { output=$(elvish -norc -c " unset-env ASDF_DIR - paths = [$(cleaned_path)] - use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} + set paths = [$(cleaned_path)] + use asdftest _asdf; var asdf~ = \$_asdf:asdf~ echo \$E:ASDF_DIR ") [ "$?" -eq 0 ] @@ -30,8 +30,8 @@ cleaned_path() { @test "retains ASDF_DIR" { output=$(elvish -norc -c " set-env ASDF_DIR "/path/to/asdf" - paths = [$(cleaned_path)] - use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} + set paths = [$(cleaned_path)] + use asdftest _asdf; var asdf~ = \$_asdf:asdf~ echo \$E:ASDF_DIR ") [ "$?" -eq 0 ] @@ -41,8 +41,8 @@ cleaned_path() { @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} + set paths = [$(cleaned_path)] + use asdftest _asdf; var asdf~ = \$_asdf:asdf~ echo \$E:ASDF_DATA_DIR ") [ "$?" -eq 0 ] @@ -52,8 +52,8 @@ cleaned_path() { @test "adds asdf dirs to PATH" { result=$(elvish -norc -c " unset-env ASDF_DIR - paths = [$(cleaned_path)] - use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} + set paths = [$(cleaned_path)] + use asdftest _asdf; var asdf~ = \$_asdf:asdf~ echo \$E:PATH ") [ "$?" -eq 0 ] @@ -65,8 +65,8 @@ cleaned_path() { @test "defines the _asdf namespace" { output=$(elvish -norc -c " unset-env ASDF_DIR - paths = [$(cleaned_path)] - use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} + set paths = [$(cleaned_path)] + use asdftest _asdf; var asdf~ = \$_asdf:asdf~ pprint \$_asdf: ") [ "$?" -eq 0 ] @@ -76,8 +76,8 @@ cleaned_path() { @test "defines the asdf function" { output=$(elvish -norc -c " unset-env ASDF_DIR - paths = [$(cleaned_path)] - use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} + set paths = [$(cleaned_path)] + use asdftest _asdf; var asdf~ = \$_asdf:asdf~ pprint \$asdf~ ") [ "$?" -eq 0 ] @@ -88,8 +88,8 @@ cleaned_path() { @test "function calls asdf command" { result=$(elvish -norc -c " set-env ASDF_DIR $(pwd) - paths = [$(cleaned_path)] - use asdftest _asdf; fn asdf [@args]{_asdf:asdf \$@args} + set paths = [$(cleaned_path)] + use asdftest _asdf; var asdf~ = \$_asdf:asdf~ asdf info ") [ "$?" -eq 0 ]