#!/bin/bash
# Set an attribute on a dataset in the current working directory.
# The only dependency for this script is the jq utility.
# Attributes are set for datasets by updating a field in the
# JSON object found in ._wb/index.json

set -e

echo "Setting attribute $1 to $2" >> ._wb/log.txt

cat ._wb/index.json \
| jq --arg key $1 --arg val $2 '. + {($key): $val}' \
> ._wb/index.json.updated \
&& mv ._wb/index.json.updated ._wb/index.json