Skip to content

Commit c6b7cc5

Browse files
committed
chore: add more jq scripts
1 parent 30061de commit c6b7cc5

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

scripts/jq/jq-fuzzy-name.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
[ -z "$1" ] && echo "error: expects a query to be passed" && exit 1
4+
5+
bash scripts/jq/jq-all-cards.sh \
6+
| jq --arg name "$1" '[.[] | select(.name | test($name; "i"))]'

scripts/jq/search-cards.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
query=$(gum input --prompt="Card name (fuzzy)> ")
4+
[[ -z $query ]] && exit 1
5+
6+
results=$(bash scripts/jq/jq-fuzzy-name.sh "$query" | jq -r '.[] | "\(.pack_id)@\(.id)"')
7+
8+
packs_file=$(bash scripts/jq/locate-pack-json.sh)
9+
lang_sub_dir=$(dirname "$packs_file")
10+
images_dir="$lang_sub_dir/images"
11+
12+
echo "$results" | fzf --preview="scripts/jq/card-previewer.sh {} $images_dir" --height 80%

scripts/jq/show-rarities-per-pack.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ bash scripts/jq/jq-rarities-per-pack.sh \
2424
uncommon=$(echo "$pack" | jq '.rarity_counts[] | select(.rarity == "Uncommon") | .count' || echo 0)
2525
common=$(echo "$pack" | jq '.rarity_counts[] | select(.rarity == "Common") | .count' || echo 0)
2626

27+
all_count=$(echo "$pack" | jq '[.rarity_counts[].count] | add')
28+
2729
gold_sum="${FG_YELLOW}${secret_rare:-0} 🌟 ${treasure_rare:-0}${COL_RESET}"
2830
purple_sum="${FG_PURPLE}${super_rare:-0}${special:-0}${COL_RESET}"
31+
pack_name="${FG_BLUE}$pack_name${COL_RESET}"
2932

30-
echo -e "(${FG_RED}$pack_id${COL_RESET}) $gold_sum / $purple_sum ${COL_RESET}${FG_BLUE}$pack_name${COL_RESET}"
33+
echo -e "(${FG_RED}$pack_id${COL_RESET}) $gold_sum / $purple_sum $pack_name => $all_count"
3134
done;

0 commit comments

Comments
 (0)