#include #include #include "main.h" #include "Pokedex.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?: "; if (!std::getline(cin, search_query)) break; std::vector cards = g_pokedex->search_cards_by_id(search_query); size_t card_count = cards.size(); if (card_count == 0) { cout << "no cards found" << endl; } else if (card_count == 1) { cout << "found card:" << endl << *cards[0]; } else { cout << "found cards:" << endl; for (PokemonCard* card : cards) cout << *card << 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 << "export mode! let's convert " << csv_file << " to " << zip_file << endl; return EXIT_SUCCESS; } int main(int argc, char** argv) { // PokemonTCGAPIClient api_client_test; // std::vector sets = api_client_test.get_sets(); // for (auto s : sets) // cout << s << endl; // return EXIT_SUCCESS; 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; }