Skip to content

Commit e962639

Browse files
authored
Merge pull request asdf-vm#78 from duijf/argument-validation. Thank you @duijf ~!
Argument validation
2 parents 1589a03 + ccefa99 commit e962639

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎lib/commands/plugin-add.sh‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
plugin_add_command() {
2+
if [ "$#" -ne 2 ]; then
3+
display_error "usage: asdf plugin-add <name> <git-url>"
4+
exit 1
5+
fi
6+
27
local plugin_name=$1
38
local source_url=$2
49
local plugin_path=$(get_plugin_path $plugin_name)
510

611
mkdir -p $(asdf_dir)/plugins
712

813
if [ -d $plugin_path ]; then
9-
echo "Plugin named $plugin_name already added"
14+
display_error "Plugin named $plugin_name already added"
1015
exit 1
1116
else
1217
git clone $source_url $plugin_path

‎lib/commands/plugin-update.sh‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
plugin_update_command() {
2+
if [ "$#" -ne 1 ]; then
3+
display_error "usage: asdf plugin-update {<name> | --all}"
4+
exit 1
5+
fi
6+
27
local plugin_name=$1
38
if [ "$plugin_name" = "--all" ]; then
49
for dir in $(asdf_dir)/plugins/*; do

0 commit comments

Comments
 (0)