Dustin Lam | 3c47192 | 2020-07-28 15:59:00 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | BASE_URL="https://plugins.jetbrains.com" |
| 4 | SCRIPT_PATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" |
| 5 | STUDIO_DIR=`ls -d $SCRIPT_PATH/../studio/*` |
| 6 | STUDIO_BUILD=`cat "$STUDIO_DIR"/android-studio/product-info.json \ |
| 7 | | jq -r '.productCode + "-" + .buildNumber'` |
| 8 | |
| 9 | if [[ -z "$1" ]] || [[ "$1" == "help" ]]; then |
| 10 | echo -n \ |
| 11 | "usage: plugins <command> [<args>] |
| 12 | |
| 13 | A CLI for JB's plugin marketplace that supports querying and installing plugins that support the current version of Studio. |
| 14 | |
| 15 | Commands: |
| 16 | help Display this help text |
| 17 | ls [<query>] Query plugin marketplace by plugin name for plugin ids supporting the current version of Studio |
| 18 | install <id> Download and install plugins by plugin id |
| 19 | " |
| 20 | elif [[ $1 == "ls" ]]; then |
| 21 | QUERY="$2" |
| 22 | curl -s "$BASE_URL/plugins/list?build=$STUDIO_BUILD" \ |
| 23 | | egrep -o "<name>[^<]+</name><id>[a-zA-Z0-9\.]+</id>" \ |
| 24 | | sed 's/<id>/id: /g' \ |
| 25 | | sed 's/<\/id>//g' \ |
| 26 | | sed 's/<name>/name: /g' \ |
| 27 | | sed 's/<\/name>/>/g' \ |
| 28 | | grep -i "$QUERY" \ |
| 29 | | column -t -s\> |
| 30 | elif [[ $1 == "install" ]]; then |
| 31 | ID="$2" |
| 32 | wget "$BASE_URL/pluginManager?action=download&id=$ID&build=$STUDIO_BUILD" -O ~/.dustinlam_plugins_download \ |
| 33 | && unzip -od "$STUDIO_DIR/android-studio/plugins" ~/.dustinlam_plugins_download |
| 34 | elif [[ $1 == "help" ]]; then |
| 35 | echo "ls [query]" |
| 36 | echo "install [id]" |
| 37 | fi |