Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
feat: upgrade elvish to 0.17.0 (#1159)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
brunoroque06 authored Feb 11, 2022
1 parent 2a538fe commit 824550e
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 114 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 24 additions & 24 deletions asdf.elv
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -31,31 +31,31 @@ 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
}
}
}
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
Expand All @@ -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)
}
}
Expand All @@ -87,20 +87,20 @@ for path [
$asdf_data_dir'/shims'
] {
if (not (has-value $paths $path)) {
paths = [
set paths = [
$@paths
$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'
Expand Down Expand Up @@ -176,7 +176,7 @@ fn arg-completer [@argz]{
put '--parent'
} elif (or (match $argz 'plugin-add') (match $argz 'plugin' 'add')) {
# asdf plugin add <name>
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')) {
Expand All @@ -190,13 +190,13 @@ fn arg-completer [@argz]{
} elif (or (match $argz 'plugin-remove') (match $argz 'plugin' 'remove')) {
# asdf plugin remove <name>
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 <plugin-name> <plugin-url> [--asdf-tool-version <version>] [--asdf-plugin-gitref <git-ref>] [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 <plugin-name> <plugin-url> [--asdf-tool-version <version>] [--asdf-plugin-gitref <git-ref>] [test-command*]
put '--asdf-plugin-gitref'
put '--asdf-tool-version'
Expand All @@ -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') {
Expand Down
24 changes: 12 additions & 12 deletions docs/guide/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -162,25 +162,25 @@ 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.
:::

::: 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.
Expand Down
24 changes: 12 additions & 12 deletions docs/manage/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
24 changes: 12 additions & 12 deletions docs/pt-br/guide/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -162,25 +162,25 @@ 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.
:::

::: 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.
Expand Down
24 changes: 12 additions & 12 deletions docs/pt-br/manage/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
Loading

0 comments on commit 824550e

Please sign in to comment.