main.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #pragma once
  2. #include <iostream>
  3. #include "core/entry.h"
  4. #include <filesystem>
  5. std::string config_filepath;
  6. void* fastweb_app_ptr = nullptr;
  7. void start()
  8. {
  9. fastweb_app_ptr = fastweb_start(config_filepath.c_str());
  10. }
  11. void close()
  12. {
  13. if(fastweb_app_ptr == nullptr)
  14. fastweb_close(fastweb_app_ptr);
  15. fastweb_app_ptr = nullptr;
  16. }
  17. int main()
  18. {
  19. config_filepath = std::filesystem::current_path().string() + "/config.ini";
  20. std::string input = "restart";
  21. while (true)
  22. {
  23. if (input == "restart")
  24. {
  25. std::cout << "closing..." << std::endl;
  26. close();
  27. std::cout << "starting..." << std::endl;
  28. start();
  29. if (fastweb_app_ptr == nullptr)
  30. {
  31. std::cin.get();
  32. return -1;
  33. }
  34. std::cout << "started" << std::endl;
  35. }
  36. else if (input == "quit" || input == "exit")
  37. {
  38. close();
  39. std::cout << "closed";
  40. break;
  41. }
  42. else
  43. {
  44. std::cout << "Enter \"quit\" or \"exit\" to exit the application" << std::endl;
  45. std::cout << "Enter \"restart\" to restart the application" << std::endl;
  46. }
  47. std::cin >> input;
  48. }
  49. return 0;
  50. }