#!/bin/bash

# SPDX-FileCopyrightText: 2023 Johannes Loher
#
# SPDX-License-Identifier: MIT

pack() {
    packs=$(ls -1 ./packs)
    for pack in $packs; do
        pnpm exec fvtt package pack --type=System --compendiumName=$pack --inputDirectory=./packs/$pack --outputDirectory=./dist/packs
    done
}

unpack() {
    packs=$(ls -1 ./dist/packs | tr '\n' ' ')
    rm -rf ./packs/*
    for pack in $packs; do
        pnpm exec fvtt package unpack --type=System --compendiumName=$pack --inputDirectory=./dist/packs --outputDirectory=./packs/$pack
    done
}

case $1 in
    "pack") pack
    ;;
    "unpack") unpack
    ;;
    *) echo "Usage: $0 <pack|unpack>"
    ;;
esac
