I am trying to download the latest just
binary file and I am able to do it with the following line of code in bash:
wget -q $(curl -s https://api.github.com/repos/casey/just/releases/latest | python -c 'import json,sys;print(json.load(sys.stdin)["assets"][-1]["browser_download_url"])')
This works, but I am using curl
and wget
together which I feel looks wrong. Is there a way to do this with just wget
?
wget URL
is the mostly the same as curl -O URL
.
curl
is mostly the same as wget -o- URL
.
But since you are already using python, why not initiate the HTTP request directly from python?
Or instead of using python, use jq to extract the relevant bits from the JSON:
curl -O "$(curl https://api.github.com/repos/casey/just/releases/latest |
jq -r '.assets|last|.browser_download_url')"