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
|
||||
asdf plugin-list
|
||||
# asdf plugin-list
|
||||
# java
|
||||
# nodejs
|
||||
```
|
||||
|
||||
```bash
|
||||
asdf plugin-list --urls
|
||||
# asdf plugin-list
|
||||
# java https://github.com/skotchpine/asdf-java.git
|
||||
# nodejs https://github.com/asdf-vm/asdf-nodejs.git
|
||||
```
|
||||
|
3
help.txt
3
help.txt
@ -1,7 +1,8 @@
|
||||
MANAGE PLUGINS
|
||||
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
|
||||
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-remove <name> Remove plugin and package versions
|
||||
asdf plugin-update <name> Update plugin
|
||||
|
@ -16,20 +16,17 @@ plugin_current_command() {
|
||||
check_for_deprecated_plugin "$plugin_name"
|
||||
|
||||
if [ -z "$version" ]; then
|
||||
printf "No version set for $plugin_name"
|
||||
printf "%s\\n" "No version set for $plugin_name"
|
||||
exit 1
|
||||
else
|
||||
printf "%-8s%s" "$version" "(set by" "$version_file_path)"
|
||||
printf "%-8s%s\\n" "$version" "(set by $version_file_path)"
|
||||
fi
|
||||
}
|
||||
|
||||
current_command() {
|
||||
if [ $# -eq 0 ]; then
|
||||
for plugin in $(plugin_list_command); do
|
||||
#plugin_list_command returns <name url> pairs, so filter urls
|
||||
if [[ $plugin != *"http"* ]] ; then
|
||||
printf "%-15s%s\\n" "$plugin" "$(plugin_current_command "$plugin")"
|
||||
fi
|
||||
done
|
||||
else
|
||||
local plugin=$1
|
||||
|
@ -1,14 +1,32 @@
|
||||
plugin_list_command() {
|
||||
local flag=$1
|
||||
|
||||
# 0 || 1 with flag
|
||||
if [ $# -eq 0 ] || ([ $# -eq 1 ] && [ "$flag" == "--urls" ]); then
|
||||
# valid command
|
||||
|
||||
local plugins_path
|
||||
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"
|
||||
printf "%s\\n" 'Oohes nooes ~! No plugins installed'
|
||||
fi
|
||||
|
||||
else
|
||||
display_error "usage: asdf plugin-list [--urls]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ teardown() {
|
||||
|
||||
run plugin_list_command
|
||||
# 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" {
|
||||
|
Loading…
Reference in New Issue
Block a user