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 1 commit
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
44 changes: 22 additions & 22 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 {||
brunoroque06 marked this conversation as resolved.
Show resolved Hide resolved
ls $asdf_data_dir'/shims'
}

fn ls-executables []{
fn ls-executables {||
brunoroque06 marked this conversation as resolved.
Show resolved Hide resolved
# 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
brunoroque06 marked this conversation as resolved.
Show resolved Hide resolved
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 Down Expand Up @@ -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
12 changes: 6 additions & 6 deletions docs/guide/getting-started.md
Expand Up @@ -152,8 +152,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 "\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
echo "\n"'use asdf _asdf; fn asdf {|@args| _asdf:asdf $@args}' >> ~/.elvish/rc.elv
brunoroque06 marked this conversation as resolved.
Show resolved Hide resolved
echo "\n"'set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv
```

Completions are automatically configured.
Expand All @@ -166,8 +166,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 "\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
echo "\n"'use asdf _asdf; fn asdf {|@args| _asdf:asdf $@args}' >> ~/.elvish/rc.elv
echo "\n"'set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv
```

Completions are automatically configured.
Expand All @@ -179,8 +179,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 "\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
echo "\n"'use asdf _asdf; fn asdf {|@args| _asdf:asdf $@args}' >> ~/.elvish/rc.elv
echo "\n"'set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv
```

Completions are automatically configured.
Expand Down
12 changes: 6 additions & 6 deletions docs/manage/core.md
Expand Up @@ -262,8 +262,8 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc
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~
use asdf _asdf; fn asdf {|@args| _asdf:asdf $@args}
set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~
```

and uninstall the `asdf` module with this command:
Expand Down Expand Up @@ -291,8 +291,8 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc
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~
use asdf _asdf; fn asdf {|@args| _asdf:asdf $@args}
set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~
```

and uninstall the `asdf` module with this command:
Expand Down Expand Up @@ -320,8 +320,8 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc
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~
use asdf _asdf; fn asdf {|@args| _asdf:asdf $@args}
set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~
```

and uninstall the `asdf` module with this command:
Expand Down
12 changes: 6 additions & 6 deletions docs/pt-br/guide/getting-started.md
Expand Up @@ -152,8 +152,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 "\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
echo "\n"'use asdf _asdf; fn asdf {|@args| _asdf:asdf $@args}' >> ~/.elvish/rc.elv
echo "\n"'set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv
```

Completions are automatically configured.
Expand All @@ -166,8 +166,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 "\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
echo "\n"'use asdf _asdf; fn asdf {|@args| _asdf:asdf $@args}' >> ~/.elvish/rc.elv
echo "\n"'set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv
```

Completions are automatically configured.
Expand All @@ -179,8 +179,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 "\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
echo "\n"'use asdf _asdf; fn asdf {|@args| _asdf:asdf $@args}' >> ~/.elvish/rc.elv
echo "\n"'set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~' >> ~/.elvish/rc.elv
```

Completions are automatically configured.
Expand Down
12 changes: 6 additions & 6 deletions docs/pt-br/manage/core.md
Expand Up @@ -264,8 +264,8 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc
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~
use asdf _asdf; fn asdf {|@args| _asdf:asdf $@args}
set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~
```

e desinstale o módulo `asdf` com este comando:
Expand Down Expand Up @@ -293,8 +293,8 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc
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~
use asdf _asdf; fn asdf {|@args| _asdf:asdf $@args}
set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~
```

e desinstale o módulo `asdf` com este comando:
Expand Down Expand Up @@ -322,8 +322,8 @@ rm -rf $HOME/.tool-versions $HOME/.asdfrc
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~
use asdf _asdf; fn asdf {|@args| _asdf:asdf $@args}
set edit:completion:arg-completer[asdf] = $_asdf:arg-completer~
```

e desinstale o módulo `asdf` com este comando:
Expand Down