-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cpp
68 lines (61 loc) · 2.5 KB
/
Main.cpp
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
66
67
68
#include <iostream>
#include <sstream>
#include <fstream>
#include "curl/HttpClientCurl.hpp"
#include "BazPO.hpp"
#include "items/Api.hpp"
#include "items/App.hpp"
#include "items/Item.hpp"
#include "items/Database.hpp"
#include "items/JsonHelper.hpp"
int main(int argc, const char* argv[])
{
std::uint8_t ITEM_REQ_COUNT = 180;
IdDatabase idDb("items.list");
NameDatabase nameDb("items.exlist");
PriceDatabase priceDb("items.db");
FavouritesDatabase favDb {"favourites.fav"};
SortParameters parameters;
BazPO::Cli cli(argc, argv, "Guild Wars 2 Trading Post Tool / GW2-TP v2.0");
cli.flag("-e",[&](const auto& option)
{
idDb.Erase();
nameDb.Erase();
priceDb.Erase();
std::cout << "ALL DATABASES ARE ERASED!" << std::endl;
} , "Erase all databases before starting up (except favourite database)", "--erase");
cli.flag("-ef",[&](const auto& option)
{
favDb.Erase();
std::cout << "FAVOURITE DATABASE IS ERASED!" << std::endl;
} , "Erase favorite database before starting up", "--erasefavs");
cli.option("-r",[&](const auto& option)
{
ITEM_REQ_COUNT = option.valueAs<std::uint8_t>();
std::cout << "USING CUSTOM API REQUEST LIMIT: " << ITEM_REQ_COUNT << std::endl;
} , "--requests", "Amount of items per API request when downloading databases").withMaxValueCount(1)
.constrain(std::make_pair(1, 199));
cli.option("-bq",[&](const auto& option)
{
parameters.BUYQ_Limit = option.valueAs<std::uint64_t>();
std::cout << "USING BUY QUANTITY LIMIT: " << parameters.BUYQ_Limit << std::endl;
} , "--buyquantity", "Minimum amount of BUY orders required for an item", "550").withMaxValueCount(1);
cli.option("-sq",[&](const auto& option)
{
parameters.SELLQ_Limit = option.valueAs<std::uint64_t>();
std::cout << "USING SELL QUANTITY LIMIT: " << parameters.SELLQ_Limit << std::endl;
} , "--sellquantity", "Minimum amount of SELL orders required for an item", "550").withMaxValueCount(1);
cli.option("-p",[&](const auto& option)
{
auto values = option.valuesAs<std::uint64_t>();
parameters.BUYG_MIN = values[0];
parameters.BUYG_MAX = values[1];
std::cout << "USING BUY PRICE LIMITS MIN-MAX: " << parameters.BUYG_MIN << " - " << parameters.BUYG_MAX << std::endl;
} , "--price", "Buying price limits in format [min max]", "0 9999999", BazPO::OptionType::MultiValue).withMaxValueCount(2).constrain(std::make_pair(0, 9999999));
cli.parse();
GW2API api (ITEM_REQ_COUNT, idDb, nameDb, priceDb);
GW2TPAPP app(api, parameters, idDb, nameDb, priceDb, favDb);
app.UserInitialize();
app.MainMenu();
return 0;
}