forked from gadgetron/gadgetron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manifest
executable file
·44 lines (39 loc) · 1 KB
/
manifest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
function usage
{
echo "usage manifest --key <com.mykey.blah> [--value <VALUE>] [--file <FILE>]"
}
filename=/opt/manifest.json
key="."
value=""
jq_command="jq -M"
while [ "$1" != "" ]; do
case $1 in
-f | --file ) shift
filename=$1
;;
-k | --key ) shift
key=$1
;;
-v | --value ) shift
value=$1
;;
-h | --help ) usage
exit
;;
* ) usage
exit 1
esac
shift
done
if [ ! -f $filename ]; then
echo "{}" > $filename
fi
if [ -z "$value" ]; then
#This is a query
$jq_command $key $filename
else
#This is an assignment
out=`${jq_command} "$key=\"$value\"" $filename`
echo $out > $filename
fi