Created
August 21, 2017 03:30
-
-
Save nrobinson2000/f77a32c04c2fb9540c658a17009276f4 to your computer and use it in GitHub Desktop.
Get the GitHub URL for a Particle library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
getLibURL() | |
{ | |
TOKEN="$(cat ~/.particle/particle.config.json | grep 'token' | grep -oE '([0-Z])\w+')" | |
DATA=$(curl -sLH "Authorization: Bearer $TOKEN" "https://api.particle.io/v1/libraries/$1" | json_pp) | |
LIBURL=$(echo "$DATA" | grep "url" | grep -oE '"((?:\\.|[^"\\])*)"' | grep "http" | tr -d '"') | |
} | |
getLibURL "$1" | |
if ( echo "$LIBURL" | grep "github" ) > /dev/null ; | |
then | |
echo "$LIBURL" | |
else | |
echo "Not Found" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment