#include #include #include "Pokedex.h" #include "PokemonCard.h" #include "ZipExport.h" using std::endl; using std::cout; using std::cin; Pokedex* g_pokedex = nullptr; int interactive_mode() { cout << "entering interactive mode..." << endl; std::string search_query; for(;;) { cout << "card id or name?: "; if (!std::getline(cin, search_query)) break; std::vector cards = g_pokedex->search_cards(search_query); size_t card_count = cards.size(); if (card_count == 0) { cout << "no cards found" << endl; } else if (card_count == 1) { cards[0]->fetch_market_value(); cout << "found card:" << endl << *cards[0]; } else { cout << "found cards:" << endl; for (PokemonCard* card : cards) cout << card->short_identifier() << endl; } } return EXIT_SUCCESS; } int export_mode(int argc, char** argv) { std::string csv_file = argv[1]; std::string zip_file = argc == 3 ? argv[2] : ""; while (zip_file.size() == 0) { // make sure target file is given cout << "zip file location?: "; if (!std::getline(cin, zip_file)) break; } cout << "exporting cards in " << csv_file << " to " << zip_file << endl; ZipExport zip_export(g_pokedex, csv_file, zip_file); return EXIT_SUCCESS; } int main(int argc, char** argv) { g_pokedex = new Pokedex(); if (argc == 1) { // no arguments specified return interactive_mode(); } else if (argc == 2 || argc == 3) { return export_mode(argc, argv); } else { // three or more arguments cout << "too many arguments specified!" << endl; return EXIT_FAILURE; } return EXIT_SUCCESS; }