2020-01-07 20:08:18 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
2020-01-10 14:21:03 +00:00
|
|
|
#include <helpers/accounthelper.h>
|
|
|
|
|
2020-01-07 20:53:27 +00:00
|
|
|
#include "api_request.h"
|
2020-01-08 16:43:04 +00:00
|
|
|
#include "loginscreen.h"
|
|
|
|
|
2020-01-07 20:08:18 +00:00
|
|
|
using namespace std;
|
|
|
|
|
2020-01-10 14:21:03 +00:00
|
|
|
int main(int argc, char **argv)
|
2020-01-07 20:08:18 +00:00
|
|
|
{
|
|
|
|
cout << "Comunic Term (c) Pierre HUBERT" << endl;
|
2020-01-07 20:53:27 +00:00
|
|
|
|
2020-01-10 14:21:03 +00:00
|
|
|
bool onlyGetTokens = false;
|
|
|
|
|
|
|
|
if(argc > 1) {
|
|
|
|
string arg = argv[1];
|
|
|
|
|
|
|
|
// Show help
|
|
|
|
if(arg == "help") {
|
|
|
|
cout << "Usage: " << endl;
|
|
|
|
cout << "* help : Show this help" << endl;
|
|
|
|
cout << "* getTokens : Get login token ONLY" << endl;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get login tokens
|
|
|
|
if(arg == "getTokens") {
|
|
|
|
cout << "Getting only login tokens..." << endl;
|
|
|
|
onlyGetTokens = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-01-08 16:43:04 +00:00
|
|
|
// First, we need to sign in user
|
2020-01-10 14:21:03 +00:00
|
|
|
if(!LoginScreen().exec(!onlyGetTokens)) {
|
2020-01-08 16:43:04 +00:00
|
|
|
cerr << "Could not sign in user!" << endl;
|
|
|
|
return -1;
|
|
|
|
}
|
2020-01-07 20:53:27 +00:00
|
|
|
|
2020-01-10 14:21:03 +00:00
|
|
|
if(onlyGetTokens) {
|
|
|
|
const auto tokens = AccountHelper::loginTokens();
|
|
|
|
cout << "Token 1: " << tokens[0] << endl;
|
|
|
|
cout << "Token 2: " << tokens[1] << endl;
|
|
|
|
}
|
|
|
|
|
2020-01-07 20:08:18 +00:00
|
|
|
return 0;
|
|
|
|
}
|