#include "olcPGE_ResourcePack.h" #include #include void PrintUsage() { std::cout << "Usage: packer --list PACK_FILE" << std::endl; std::cout << " packer --add PACK_FILE FILE" << std::endl; std::cout << " packer --remove PACK_FILE FILE" << std::endl; // std::cout << " packer --convert PNG_FILE SPR_FILE" << std::endl; } void ListEntries(olc::ResourcePack& pack) { auto entries = pack.GetEntries(); std::cout << "Total entries: " << entries.size() << std::endl; for (auto entry: entries) { std::cout << entry << std::endl; } } int main(int argc, char *argv[]) { std::string packFile; std::string action; if (argc < 3) { PrintUsage(); return -1; } action = argv[1]; packFile = argv[2]; olc::ResourcePack pack; pack.LoadPack(packFile); if (action == "--list") { ListEntries(pack); } else if (action == "--add" || action == "--remove") { if (argc < 4) { PrintUsage(); return -1; } for (int i = 3; i < argc; i++) { std::string fileName = argv[i]; if (action == "--add") { if (!pack.AddToPack(fileName)) { std::cerr << "Could not open file " << fileName << std::endl; return -3; } std::cout << "+ " << fileName << std::endl; } else if (action == "--remove") { if (!pack.RemoveFromPack(fileName)) { std::cerr << "Could not open file " << fileName << std::endl; return -3; } std::cout << "- " << fileName << std::endl; } } std::cout << std::endl; ListEntries(pack); } else { PrintUsage(); return -1; } pack.SavePack(packFile); return 0; }