Skip to content

Commit

Permalink
feat: rename load_cards arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
beheh committed Mar 26, 2024
1 parent 2f27c49 commit 5ec78f3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions django_hearthstone/cards/management/commands/load_cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument("path", nargs="?", help="CardDefs.xml file")
parser.add_argument("--locale", default="enUS")
parser.add_argument("--force", action="store_true", help="Force update all cards")
parser.add_argument(
"--ignore-conflicts", action="store_true",
help="Ignore conflicts due to existing cards"
"--no-update", action="store_true",
help="Skip updating existing cards"
)
parser.add_argument(
"--force", action="store_true",
help="Bypass conflicts with existing cards"
)

def handle(self, *args, **options):
Expand All @@ -30,7 +33,7 @@ def handle(self, *args, **options):
Card.objects.bulk_create(new_cards)
self.stdout.write("%i new cards" % (len(new_cards)))

if options["force"]:
if not options["no_update"]:
existing = Card.objects.filter(dbf_id__in=known_ids)
for card in existing:
if card.dbf_id not in db:
Expand All @@ -44,7 +47,7 @@ def handle(self, *args, **options):
try:
card.update_from_cardxml(c, save=True)
except IntegrityError as e:
if options["ignore_conflicts"]:
if options["force"]:
self.stderr.write(
f"WARNING: Ignoring {repr(card)} ({card.dbf_id}) conflict:"
f"{e}"
Expand Down

0 comments on commit 5ec78f3

Please sign in to comment.