Add app id as first cli parameter

This commit is contained in:
Georg Hagen
2025-01-04 20:33:38 +01:00
parent fad309d96d
commit 8250b2a396

View File

@@ -19,6 +19,13 @@
using namespace OpenVulkano; using namespace OpenVulkano;
int main(int argc, char** argv) int main(int argc, char** argv)
{
int selectedExample = -1;
if (argc == 2)
{
selectedExample = strtol(argv[1], nullptr, 10);
}
if (selectedExample < 0)
{ {
std::vector<std::string> examples; std::vector<std::string> examples;
for (const auto& e : EXAMPLE_APPS) for (const auto& e : EXAMPLE_APPS)
@@ -26,12 +33,11 @@ int main(int argc, char** argv)
examples.emplace_back(e.first); examples.emplace_back(e.first);
} }
int selectedExample = 0;
ftxui::MenuOption option; ftxui::MenuOption option;
auto screen = ftxui::ScreenInteractive::TerminalOutput(); auto screen = ftxui::ScreenInteractive::TerminalOutput();
auto menu = ftxui::Menu(&examples, &selectedExample, option);
bool shouldExit = true; bool shouldExit = true;
option.on_enter = [&] { shouldExit = false; screen.ExitLoopClosure(); }; option.on_enter = [&]() { shouldExit = false; screen.ExitLoopClosure()(); };
auto menu = ftxui::Menu(&examples, &selectedExample, option);
screen.Loop(menu); screen.Loop(menu);
if (shouldExit) return 0; if (shouldExit) return 0;
@@ -40,6 +46,7 @@ int main(int argc, char** argv)
{ {
throw std::runtime_error("Invalid menu selection!"); throw std::runtime_error("Invalid menu selection!");
} }
}
std::unique_ptr<IGraphicsApp> app(EXAMPLE_APPS[selectedExample].second()); std::unique_ptr<IGraphicsApp> app(EXAMPLE_APPS[selectedExample].second());