File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11installs
22plugins
33shims
4+ repository
45.vagrant
5-
Original file line number Diff line number Diff line change 11MANAGE PLUGINS
2- asdf plugin-add <name> <git-url> Add git repo as plugin
2+ asdf plugin-add <name> [ <git-url>] Add a plugin
33 asdf plugin-list List installed plugins
44 asdf plugin-remove <name> Remove plugin and package versions
55 asdf plugin-update <name> Update plugin
Original file line number Diff line number Diff line change 11plugin_add_command () {
2- if [ " $# " -ne 2 ]; then
3- display_error " usage: asdf plugin-add <name> <git-url>"
2+ if [[ $# -lt 1 || $# -gt 2 ] ]; then
3+ display_error " usage: asdf plugin-add <name> [ <git-url>] "
44 exit 1
55 fi
66
77 local plugin_name=$1
8- local source_url=$2
8+
9+ if [ -n " $2 " ]; then
10+ local source_url=$2
11+ else
12+ initialize_or_update_repository
13+ local source_url=$( get_plugin_source_url $plugin_name )
14+ fi
15+
16+ if [ -z " $source_url " ]; then
17+ display_error " plugin $plugin_name not found in repository"
18+ exit 1
19+ fi
20+
921 local plugin_path=$( get_plugin_path $plugin_name )
1022
1123 mkdir -p $( asdf_dir) /plugins
Original file line number Diff line number Diff line change @@ -206,3 +206,29 @@ get_asdf_config_value() {
206206 get_asdf_config_value_from_file $default_config_path $key
207207 fi
208208}
209+
210+ asdf_repository_url () {
211+ echo " https://github.com/doughsay/asdf-plugins.git"
212+ }
213+
214+ initialize_or_update_repository () {
215+ local repository_url=$( asdf_repository_url)
216+ local repository_path=$( asdf_dir) /repository
217+
218+ if [ -d $repository_path ]; then
219+ echo " updating plugin repository..."
220+ (cd $repository_path && git pull)
221+ else
222+ echo " initializing plugin repository..."
223+ git clone $repository_url $repository_path
224+ fi
225+ }
226+
227+ get_plugin_source_url () {
228+ local plugin_name=$1
229+ local plugin_config=" $( asdf_dir) /repository/plugins/$plugin_name "
230+
231+ if [ -f $plugin_config ]; then
232+ cat $plugin_config | grep " repository" | awk -F' =' ' {print $2}' | sed ' s/ //'
233+ fi
234+ }
You can’t perform that action at this time.
0 commit comments