Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: upgrade elvish to 0.17.0 #1159

Merged
merged 7 commits into from Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
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
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
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
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
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
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