增加自定义控制命令
This commit is contained in:
@@ -2,25 +2,48 @@
|
||||
#include <iostream>
|
||||
#include "core/entry.h"
|
||||
#include <filesystem>
|
||||
std::string config_filepath;
|
||||
bool start()
|
||||
{
|
||||
return fastweb_start(config_filepath.c_str()) == 0;
|
||||
}
|
||||
void close()
|
||||
{
|
||||
fastweb_close();
|
||||
}
|
||||
int main()
|
||||
{
|
||||
std::string config_filepath = std::filesystem::current_path().string()+"/config.ini";
|
||||
if (fastweb_start(config_filepath.c_str()) != 0)
|
||||
return -1;
|
||||
config_filepath = std::filesystem::current_path().string() + "/config.ini";
|
||||
|
||||
std::string input = "restart";
|
||||
while (true)
|
||||
{
|
||||
std::string input;
|
||||
std::cin >> input;
|
||||
|
||||
if (input == "quit" || input == "exit")
|
||||
if (input == "restart")
|
||||
{
|
||||
fastweb_close();
|
||||
std::cout << "closing..." << std::endl;
|
||||
close();
|
||||
std::cout << "starting..." << std::endl;
|
||||
if (start() == false)
|
||||
{
|
||||
std::cin.get();
|
||||
return -1;
|
||||
}
|
||||
std::cout << "started" << std::endl;
|
||||
}
|
||||
else if (input == "quit" || input == "exit")
|
||||
{
|
||||
close();
|
||||
std::cout << "closed";
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Enter \"quit\" or \"exit\" to exit the application" << std::endl;
|
||||
std::cout << "Enter \"restart\" to restart the application" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
std::cin >> input;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user