sh Bash脚本帮助更新asdf中的插件版本

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh Bash脚本帮助更新asdf中的插件版本相关的知识,希望对你有一定的参考价值。

#!/bin/bash

# Gather constant vars
ASDF_PLUGIN=""
ASDF_NEW_PLUGIN_VERSION=""


# Declare script fuctions

# Delete other plugin versions
delete_other_plugin_versions ()
{
  for plugin_version in $(asdf list $ASDF_PLUGIN) 
  do
    if [[ $plugin_version != $ASDF_NEW_PLUGIN_VERSION ]]
    then
      echo -e "delete \e[1;32m$plugin_version\e[0m version of \e[1;34m$ASDF_PLUGIN\e[0m"
      asdf uninstall $ASDF_PLUGIN $plugin_version
    fi
  done
}

# Delete other plugin versions menu
delete_other_plugin_versions_menu ()
{
  while true; do
      read -p "Do you wish delete other $ASDF_PLUGIN versions (y/n)? " yn
      case $yn in
          [Yy]* ) delete_other_plugin_versions; break;;
          [Nn]* ) break;;
          * ) echo -e "Please answer \e[1;31myes\e[0m or \e[1;31mno\e[0m. ";;
      esac
  done
}

# set plugin name
set_plugin_name ()
{
  read -p "Type asdf plugin name: " ASDF_PLUGIN
  if [[ $ASDF_PLUGIN = "" ]]
  then
    echo "Plugin name is not be enpty"
    exit 
  fi
}


# read asdf installed plugins and versions
asdf current
echo ""

# set plugin name
set_plugin_name
echo ""

# get plugin versions
echo -e "List all \e[1;34m$ASDF_PLUGIN\e[0m versions:"
asdf list-all $ASDF_PLUGIN
echo ""

echo -e "installed version(s) of \e[1;34m$ASDF_PLUGIN\e[0m:"
asdf list $ASDF_PLUGIN
echo ""
echo -e "current version \e[1;34m$ASDF_PLUGIN\e[0m is: \e[1;32m$(asdf current $ASDF_PLUGIN)\e[0m"
echo ""

# set new plugin version
read -p "Type NEW $ASDF_PLUGIN version: " ASDF_NEW_PLUGIN_VERSION
echo ""

# delete other plugin versions menu
delete_other_plugin_versions_menu

echo ""

# install & set global new plugin version
asdf install $ASDF_PLUGIN $ASDF_NEW_PLUGIN_VERSION
asdf global $ASDF_PLUGIN $ASDF_NEW_PLUGIN_VERSION
echo ""

# report user about current state of plugin versions
echo -e "installed version(s) of \e[1;34m$ASDF_PLUGIN\e[0m:"
asdf list $ASDF_PLUGIN
echo ""
echo -e "current version \e[1;34m$ASDF_PLUGIN\e[0m is: \e[1;32m$(asdf current $ASDF_PLUGIN)\e[0m" 
echo ""

以上是关于sh Bash脚本帮助更新asdf中的插件版本的主要内容,如果未能解决你的问题,请参考以下文章

sh Wordpress:Bash安装脚本 - 下载最新的WP版本,使用用户提供的数据库名称,用户名和密码更新wp-config,创建

sh Wordpress:Bash安装脚本 - 下载最新的WP版本,使用用户提供的数据库名称,用户名和密码更新wp-config,创建

sh Bash脚本安装最新的wordpress +插件

sh Docker撰写更新程序Bash脚本

sh 使用WP CLI使用Bash脚本更新WordPress

没有为命令 java - asdf 设置版本