Skip to content

Commit

Permalink
feat: check if .plugin-versions exists before parsing args (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
aabouzaid committed Feb 11, 2024
1 parent 6fc3faa commit a57c48f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ First, setup `asdf-plugin-manager` as asdf plugin in asdf:
```shell
asdf plugin add asdf-plugin-manager https://github.com/asdf-community/asdf-plugin-manager.git
# Pin the asdf-plugin-manager version using git tag or even better using git hash which is immutable.
asdf plugin update asdf-plugin-manager v1.2.0
asdf plugin update asdf-plugin-manager v1.3.0
```

Then, install the actual `asdf-plugin-manager` CLI:

```shell
# Install specific version
asdf install asdf-plugin-manager 1.2.0
asdf install asdf-plugin-manager 1.3.0

# Set a version globally (on your ~/.tool-versions file)
asdf global asdf-plugin-manager 1.2.0
asdf global asdf-plugin-manager 1.3.0

# Now asdf-plugin-manager command is available
asdf-plugin-manager version
Expand Down
36 changes: 27 additions & 9 deletions cli/asdf-plugin-manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@

set -eo pipefail

VERSION=1.2.0
#
# Vars.
#

VERSION=1.3.0
PLUGIN_VERSIONS_FILENAME="${ASDF_PLUGIN_MANAGER_PLUGIN_VERSIONS_FILENAME:-.plugin-versions}"
ADD_CLEAN="${ASDF_PLUGIN_MANAGER_ADD_CLEAN:-FALSE}"
PLUGINS_REPOS_DIR="$(asdf info | grep ASDF_DATA_DIR | cut -d"=" -f2)/plugins"

#
# Functions.
#

print_version() {
echo "${VERSION}"
}
Expand Down Expand Up @@ -128,19 +136,29 @@ update_plugins() {
done
}

if [[ -z $1 ]]; then
#
# Main.
#

# Check basic args.
case "$1" in
help | -h | "")
print_help
;;
version | -n)
print_version
exit 0
;;
esac

# Check if the plugin versions file exists.
if ! test -f "$(print_plugin_versions_filename)"; then
echo -e "[ERROR] The '$(print_plugin_versions_filename)' file is not found. Check help for more details:\n"
print_help
fi

while test -n "$1"; do
case "$1" in
help | -h)
print_help
;;
version | -v)
print_version
exit 0
;;
export)
export_plugins
;;
Expand Down

0 comments on commit a57c48f

Please sign in to comment.