Skip to content

Commit b53ea4c

Browse files
jq functions added
1 parent b6208db commit b53ea4c

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

assets/json-funcs.jq

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
def parse_args($array):
2+
array |
3+
to_entries | .[] |
4+
if (.key == "_flags") then
5+
select ((.value | type == "array") and (.value | length != 0)) |
6+
.value | map("--" + . + " ") | join(" ") | @text
7+
else
8+
select (.value != "") |
9+
if (.value | type == "array") then
10+
"--" + .key + "=" + (.value | join(",")) + " "
11+
else
12+
"--" + .key + "=" + (.value) + " "
13+
end
14+
end
15+
;
16+
17+
def count($array):
18+
array | length
19+
;
20+
21+
def select_independants($array):
22+
array |
23+
to_entries | .[] |
24+
select((.value == -1) or (.value == "-1")) |
25+
.key
26+
;
27+
28+
def select_dependants($array):
29+
array |
30+
to_entries |
31+
map(select(.value > 0)) |
32+
sort_by(.value) |
33+
.[].key
34+
;

0 commit comments

Comments
 (0)