blob: 4cd99ec3a9e23b2431af9211c8a7975be94a1897 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#include <cstdlib>
#include <iostream>
#include "Pokedex.h"
#include "PokemonCard.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<PokemonCard*> 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) {
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 << "export mode! let's convert " << csv_file << " to " << zip_file << endl;
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;
}
|