mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
add --urls
flag for asdf list-plugins
Fixed tests due to use of printf
This commit is contained in:
parent
88d47bbd69
commit
f99bdc75c0
@ -91,6 +91,13 @@ asdf plugin-add <name> <git-url>
|
|||||||
```bash
|
```bash
|
||||||
asdf plugin-list
|
asdf plugin-list
|
||||||
# asdf plugin-list
|
# asdf plugin-list
|
||||||
|
# java
|
||||||
|
# nodejs
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
asdf plugin-list --urls
|
||||||
|
# asdf plugin-list
|
||||||
# java https://github.com/skotchpine/asdf-java.git
|
# java https://github.com/skotchpine/asdf-java.git
|
||||||
# nodejs https://github.com/asdf-vm/asdf-nodejs.git
|
# nodejs https://github.com/asdf-vm/asdf-nodejs.git
|
||||||
```
|
```
|
||||||
|
3
help.txt
3
help.txt
@ -1,7 +1,8 @@
|
|||||||
MANAGE PLUGINS
|
MANAGE PLUGINS
|
||||||
asdf plugin-add <name> [<git-url>] Add a plugin from the plugin repo OR, add a Git repo
|
asdf plugin-add <name> [<git-url>] Add a plugin from the plugin repo OR, add a Git repo
|
||||||
as a plugin by specifying the name and repo url
|
as a plugin by specifying the name and repo url
|
||||||
asdf plugin-list List installed plugins with repository URLs
|
asdf plugin-list List installed plugins
|
||||||
|
asdf plugin-list --urls List installed plugins with repository URLs
|
||||||
asdf plugin-list-all List plugins registered on asdf-plugins repository with URLs
|
asdf plugin-list-all List plugins registered on asdf-plugins repository with URLs
|
||||||
asdf plugin-remove <name> Remove plugin and package versions
|
asdf plugin-remove <name> Remove plugin and package versions
|
||||||
asdf plugin-update <name> Update plugin
|
asdf plugin-update <name> Update plugin
|
||||||
|
@ -16,20 +16,17 @@ plugin_current_command() {
|
|||||||
check_for_deprecated_plugin "$plugin_name"
|
check_for_deprecated_plugin "$plugin_name"
|
||||||
|
|
||||||
if [ -z "$version" ]; then
|
if [ -z "$version" ]; then
|
||||||
printf "No version set for $plugin_name"
|
printf "%s\\n" "No version set for $plugin_name"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
printf "%-8s%s" "$version" "(set by" "$version_file_path)"
|
printf "%-8s%s\\n" "$version" "(set by $version_file_path)"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
current_command() {
|
current_command() {
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
for plugin in $(plugin_list_command); do
|
for plugin in $(plugin_list_command); do
|
||||||
#plugin_list_command returns <name url> pairs, so filter urls
|
printf "%-15s%s\\n" "$plugin" "$(plugin_current_command "$plugin")"
|
||||||
if [[ $plugin != *"http"* ]] ; then
|
|
||||||
printf "%-15s%s\\n" "$plugin" "$(plugin_current_command "$plugin")"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
local plugin=$1
|
local plugin=$1
|
||||||
|
@ -1,14 +1,32 @@
|
|||||||
plugin_list_command() {
|
plugin_list_command() {
|
||||||
local plugins_path
|
local flag=$1
|
||||||
plugins_path=$(get_plugin_path)
|
|
||||||
|
|
||||||
if ls "$plugins_path" &> /dev/null; then
|
# 0 || 1 with flag
|
||||||
for plugin_path in $plugins_path/* ; do
|
if [ $# -eq 0 ] || ([ $# -eq 1 ] && [ "$flag" == "--urls" ]); then
|
||||||
plugin_name=$(basename "$plugin_path")
|
# valid command
|
||||||
source_url=$(get_plugin_source_url "$plugin_name")
|
|
||||||
printf "%-15s %s\\n" "$plugin_name" "$source_url"
|
local plugins_path
|
||||||
done
|
plugins_path=$(get_plugin_path)
|
||||||
|
|
||||||
|
if ls "$plugins_path" &> /dev/null; then
|
||||||
|
for plugin_path in $plugins_path/* ; do
|
||||||
|
plugin_name=$(basename "$plugin_path")
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
printf "%s\\n" "$plugin_name"
|
||||||
|
else
|
||||||
|
source_url=$(get_plugin_source_url "$plugin_name")
|
||||||
|
printf "%-15s %s\\n" "$plugin_name" "$source_url"
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
else
|
||||||
|
printf "%s\\n" 'Oohes nooes ~! No plugins installed'
|
||||||
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
printf "%s\\n" "Oohes nooes ~! No plugins installed"
|
display_error "usage: asdf plugin-list [--urls]"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ teardown() {
|
|||||||
|
|
||||||
run current_command "dummy"
|
run current_command "dummy"
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[ "$output" = "1.1.0 (set by $PROJECT_DIR/.tool-versions)" ]
|
[ "$output" = "1.1.0 (set by $PROJECT_DIR/.tool-versions)" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "current should derive from the legacy file if enabled" {
|
@test "current should derive from the legacy file if enabled" {
|
||||||
@ -35,7 +35,7 @@ teardown() {
|
|||||||
|
|
||||||
run current_command "dummy"
|
run current_command "dummy"
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[ "$output" = "1.2.0 (set by $PROJECT_DIR/.dummy-version)" ]
|
[ "$output" = "1.2.0 (set by $PROJECT_DIR/.dummy-version)" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "current should error when the plugin doesn't exist" {
|
@test "current should error when the plugin doesn't exist" {
|
||||||
@ -75,9 +75,9 @@ teardown() {
|
|||||||
echo 'foobar 1.0.0' >> $PROJECT_DIR/.tool-versions
|
echo 'foobar 1.0.0' >> $PROJECT_DIR/.tool-versions
|
||||||
|
|
||||||
run current_command
|
run current_command
|
||||||
expected="baz No version set for baz
|
expected="baz No version set for baz
|
||||||
dummy 1.1.0 (set by $PROJECT_DIR/.tool-versions)
|
dummy 1.1.0 (set by $PROJECT_DIR/.tool-versions)
|
||||||
foobar 1.0.0 (set by $PROJECT_DIR/.tool-versions)"
|
foobar 1.0.0 (set by $PROJECT_DIR/.tool-versions)"
|
||||||
|
|
||||||
[ "$expected" = "$output" ]
|
[ "$expected" = "$output" ]
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ teardown() {
|
|||||||
|
|
||||||
run plugin_list_command
|
run plugin_list_command
|
||||||
# whitespace between 'elixir' and url is from printf %-15s %s format
|
# whitespace between 'elixir' and url is from printf %-15s %s format
|
||||||
[ "$output" = "elixir https://github.com/asdf-vm/asdf-elixir" ]
|
[ "$output" = "elixir" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "plugin_add command with no URL specified fails if the plugin doesn't exist" {
|
@test "plugin_add command with no URL specified fails if the plugin doesn't exist" {
|
||||||
|
Loading…
Reference in New Issue
Block a user