#!/bin/bash api_key="${1}" skel="${2}" plugin="${3}" name="${4:=${3#*/}}" if ! [[ -e ${skel} ]] || [[ -z ${api_key} ]] || [[ -z ${plugin} ]]; then >&2 echo "usage: ${0} " exit -1 fi echo "generating app-nvim/${name}" repo_info=$(curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer ${api_key}" \ https://api.github.com/repos/${plugin} 2>/dev/null) src=https://github.com/${plugin} desc=$(jq -r .description <<< ${repo_info}) license=$(jq -r .license.spdx_id <<< ${repo_info}) url=$(jq -r .html_url <<< ${repo_info}) mkdir -p app-nvim/${name} sed -e "s#@DESCRIPTION@#${desc}#" \ -e "s#@URI@#${url}#" \ -e "s#@SRC@#${src}#" \ -e "s#@LICENSE@#${license}#" \ -e "s#@PLUGIN@#${plugin}#" \ ${skel} > app-nvim/${name}/${name}-9999.ebuild