Add function to fetch FOSS licenses

This commit is contained in:
Jeffrey Serio 2022-07-21 15:57:06 -05:00
parent c57e04c615
commit 89ab5ae878

View File

@ -41,3 +41,24 @@ EOF
) | bat -p ) | bat -p
} }
## fetch open source license
license() {
local base_url
base_url="https://api.github.com/licenses"
local headers
headers="Accept: application/vnd.github.drax-preview+json"
local res
if (( $# == 0 )); then
res=$(curl --silent --header $headers $base_url)
echo "Available licenses:"
echo
echo "$res" | jq ".[].key" | tr -d '"'
fi
local license="$argv[1]"
res=$(curl --silent --header $headers $base_url/$license | jq ."body")
echo -e $res | tr -d '"'
}