Skip to content

Commit ced31d3

Browse files
committed
Add new option -w that prints in wave order
This replaces the old option -r which now prints in absolute release order.
1 parent e909394 commit ced31d3

File tree

2 files changed

+64
-6
lines changed

2 files changed

+64
-6
lines changed

README.md

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Command-line interface for viewing decks and decklists.
44

5-
By default mcdbcli prints the deck sorted by aspect and pack.
5+
By default mcdbcli prints the deck sorted by aspect and release order.
66

77
## Options
88

@@ -20,6 +20,8 @@ mcdbcli -l 36680
2020

2121
-r : Print in release order
2222

23+
-w : Print in waves ordered by aspect
24+
2325
Without -d or -l arguments `mcdbcli` will read deck as JSON from stdin
2426

2527
```sh
@@ -33,7 +35,7 @@ using the OAuth API yourself, and feed the JSON to mcdbcli via stdin.
3335

3436
## Example
3537

36-
Print a popular decklist:
38+
Print a popular decklist by aspect:
3739

3840
```console
3941
$ mcdbcli -l 13922
@@ -80,10 +82,10 @@ Wild Tutor - Adam Warlock
8082
1 × Gamora (Wave #3 Drax #20)
8183
```
8284

83-
Print a popular decklist in release order:
85+
Print a popular decklist by wave and aspect:
8486

8587
```console
86-
$ mcdbcli -l 13922 -r
88+
$ mcdbcli -l 13922 -w
8789
Wild Tutor - Adam Warlock
8890
Wave #1
8991
Aggression cards
@@ -139,6 +141,47 @@ Wave #4
139141
1 × Shield Spell (Wave #4 The Mad Titan's Shadow #61)
140142
```
141143

144+
Print a popular deck in absolute release order:
145+
146+
```console
147+
$ mcdbcli -l 13922 -r
148+
Wild Tutor - Adam Warlock
149+
1 × The Power of Aggression (Wave #1 Core Set #55)
150+
1 × The Power of Justice (Wave #1 Core Set #62)
151+
1 × The Power of Leadership (Wave #1 Core Set #72)
152+
1 × The Power of Protection (Wave #1 Core Set #79)
153+
1 × Nick Fury (Wave #1 Core Set #84)
154+
1 × Energy (Wave #1 Core Set #88)
155+
1 × Genius (Wave #1 Core Set #89)
156+
1 × Strength (Wave #1 Core Set #90)
157+
1 × Tackle (Wave #1 Ms. Marvel #15)
158+
1 × Concussive Blow (Wave #1 Ms. Marvel #31)
159+
1 × Brother Voodoo (Wave #1 Doctor Strange #12)
160+
1 × The Sorcerer Supreme (Wave #1 Doctor Strange #26)
161+
1 × Drop Kick (Wave #1 Hulk #14)
162+
1 × Martial Prowess (Wave #1 Hulk #18)
163+
1 × The Power in All of Us (Wave #2 Wasp #24)
164+
1 × Spiritual Meditation (Wave #2 Scarlet Witch #19)
165+
1 × Deft Focus (Wave #3 Galaxy's Most Wanted #24)
166+
1 × Gamora (Wave #3 Drax #20)
167+
1 × "Think Fast!" (Wave #3 Drax #31)
168+
1 × "Welcome Aboard" (Wave #3 Venom #27)
169+
1 × Kaluu (Wave #4 The Mad Titan's Shadow #14)
170+
1 × Pip the Troll (Wave #4 The Mad Titan's Shadow #32)
171+
1 × Soul World (Wave #4 The Mad Titan's Shadow #33)
172+
1 × Karmic Staff (Wave #4 The Mad Titan's Shadow #34)
173+
1 × Warlock's Cape (Wave #4 The Mad Titan's Shadow #35)
174+
2 × Cosmic Ward (Wave #4 The Mad Titan's Shadow #36)
175+
2 × Mystic Senses (Wave #4 The Mad Titan's Shadow #37)
176+
3 × Karmic Blast (Wave #4 The Mad Titan's Shadow #38)
177+
2 × Cosmic Awareness (Wave #4 The Mad Titan's Shadow #39)
178+
2 × Quantum Magic (Wave #4 The Mad Titan's Shadow #40)
179+
1 × Magic Attack (Wave #4 The Mad Titan's Shadow #43)
180+
1 × Zone of Silence (Wave #4 The Mad Titan's Shadow #50)
181+
1 × Summoning Spell (Wave #4 The Mad Titan's Shadow #55)
182+
1 × Shield Spell (Wave #4 The Mad Titan's Shadow #61)
183+
```
184+
142185
## Caching
143186

144187
mcdbcli caches the loaded cards to your home directory under `~/.mcdb/cards`. To remove the cached cards run the following command

mcdbcli

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
declare MCDB_API_URL='https://marvelcdb.com/api/public'
44
declare CARDS_CACHE="${HOME}/.mcdb/cards"
5+
declare WAVE_ORDER=false
56
declare RELEASE_ORDER=false
67
declare DECK_JSON
78

@@ -160,6 +161,14 @@ print_waves() {
160161
done
161162
}
162163

164+
print_cards() {
165+
local IFS='
166+
'
167+
for card_json in $(jq -cn 'inputs' "$@"); do
168+
print_card "$card_json"
169+
done
170+
}
171+
163172
print_deck() {
164173
local deck_name=$(jq -r '.name' <<<"$DECK_JSON")
165174

@@ -170,7 +179,7 @@ print_deck() {
170179
card_files+=($(get_card_file $card_id_json))
171180
done
172181

173-
if $RELEASE_ORDER; then
182+
if $WAVE_ORDER; then
174183
local cards_json=$(jq -cn '[inputs] | group_by(.code | .[0:2] | tonumber |
175184
if . < 11 then 1
176185
elif . < 16 then 2
@@ -182,6 +191,9 @@ print_deck() {
182191
elif . < 50 then 8
183192
else 99 end)' "${card_files[@]}")
184193
print_waves "$cards_json"
194+
elif $RELEASE_ORDER; then
195+
# local cards_json=$(jq -cn '[inputs]' "${card_files[@]}")
196+
print_cards "${card_files[@]}"
185197
else
186198
local cards_json=$(jq -cn '[inputs] | group_by(.faction_code |
187199
if . == "hero" then 1
@@ -196,7 +208,7 @@ print_deck() {
196208
fi
197209
}
198210

199-
while getopts 'd:l:r' opt; do
211+
while getopts 'd:l:rw' opt; do
200212
case $opt in
201213
d)
202214
DECK_JSON="$(curl -s "${MCDB_API_URL}/deck/${OPTARG}")"
@@ -207,6 +219,9 @@ while getopts 'd:l:r' opt; do
207219
r)
208220
RELEASE_ORDER=true
209221
;;
222+
w)
223+
WAVE_ORDER=true
224+
;;
210225
esac
211226
done
212227

0 commit comments

Comments
 (0)