Progress: 25%.
This commit is contained in:
commit
2fd0d6d3d4
1 changed files with 917 additions and 0 deletions
50
main.cpp
Normal file
50
main.cpp
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#include <QCoreApplication>
|
||||
#include <expected>
|
||||
#include <iostream>
|
||||
#include "mainscreen.h"
|
||||
|
||||
std::expected<std::string, int> parseArgs(int argc, char **argv) {
|
||||
std::vector<std::string> arg_list;
|
||||
for(int i=1;i < argc; i++) {
|
||||
arg_list.push_back(argv[i]);
|
||||
}
|
||||
if (argc == 1) {
|
||||
return "";
|
||||
}
|
||||
if(argc == 2) {
|
||||
return arg_list[0];
|
||||
}
|
||||
else {
|
||||
return std::unexpected(1);
|
||||
}
|
||||
}
|
||||
|
||||
void printHelp(int t) {
|
||||
if(t == 1) {
|
||||
std::cout << "Invalid number of arguments." << std::endl;
|
||||
}
|
||||
std::cout << "USAGE: nekodl [Search Term]" << std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication a(argc, argv);
|
||||
auto args = parseArgs(argc, argv);
|
||||
if(!args.has_value()) {
|
||||
printHelp(args.error());
|
||||
return -1;
|
||||
}
|
||||
MainScreen screen(args.value());
|
||||
// Set up code that uses the Qt event loop here.
|
||||
// Call QCoreApplication::quit() or QCoreApplication::exit() to quit the application.
|
||||
// A not very useful example would be including
|
||||
// #include <QTimer>
|
||||
// near the top of the file and calling
|
||||
// QTimer::singleShot(5000, &a, &QCoreApplication::quit);
|
||||
// which quits the application after 5 seconds.
|
||||
|
||||
// If you do not need a running Qt event loop, remove the call
|
||||
// to QCoreApplication::exec() or use the Non-Qt Plain C++ Application template.
|
||||
|
||||
return QCoreApplication::exec();
|
||||
}
|
||||
Loading…
Reference in a new issue