Skip to content

Instantly share code, notes, and snippets.

@zacharysyoung
Last active April 19, 2020 05:23
Show Gist options
  • Save zacharysyoung/418b42913589b6dd4b72f39f28b0b474 to your computer and use it in GitHub Desktop.
Save zacharysyoung/418b42913589b6dd4b72f39f28b0b474 to your computer and use it in GitHub Desktop.
jq scripts for transforming JSON output into shell scripts
"#!/bin/zsh",
"BASE_URL=https://pivotaltracker.com",
(. [] |
.id as $sid | (
"\nmkdir \($sid)",
(
.comments[].file_attachments[] |
"curl --location -s -H \"X-TrackerToken: $TOKEN\" \"$BASE_URL\(.download_url)\" > \($sid)/\(.id)_\(.filename)"
)
)
)
#!/bin/zsh
jq -r -f make.jq stories.json
# Makes...
# #!/bin/zsh
# BASE_URL=https://pivotaltracker.com
#
# mkdir 172365518
# curl --location -s -H "X-TrackerToken: $TOKEN" "$BASE_URL/file_attachments/103519756/download" > 172365518/103519756_mercury_sodium_emission_spectra.jpg
#
# mkdir 172365645
# curl --location -s -H "X-TrackerToken: $TOKEN" "$BASE_URL/file_attachments/103519919/download" > 172365645/103519919_fireworks_spectra.jpg
[
{
"id": 172365518,
"name": "Download a Pivotal Attachment",
"comments": [
{
"id": 213504554,
"file_attachments": [
{
"id": 103519756,
"filename": "mercury_sodium_emission_spectra.jpg",
"download_url": "/file_attachments/103519756/download"
}
]
}
]
},
{
"id": 172365645,
"name": "Download a Pivotal Attachment",
"comments": [
{
"id": 213505327,
"file_attachments": [
{
"id": 103519919,
"filename": "fireworks_spectra.jpg",
"download_url": "/file_attachments/103519919/download"
}
]
}
]
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment