Add app id as first cli parameter
This commit is contained in:
@@ -20,25 +20,32 @@ using namespace OpenVulkano;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
std::vector<std::string> examples;
|
||||
for (const auto& e : EXAMPLE_APPS)
|
||||
int selectedExample = -1;
|
||||
if (argc == 2)
|
||||
{
|
||||
examples.emplace_back(e.first);
|
||||
selectedExample = strtol(argv[1], nullptr, 10);
|
||||
}
|
||||
|
||||
int selectedExample = 0;
|
||||
ftxui::MenuOption option;
|
||||
auto screen = ftxui::ScreenInteractive::TerminalOutput();
|
||||
auto menu = ftxui::Menu(&examples, &selectedExample, option);
|
||||
bool shouldExit = true;
|
||||
option.on_enter = [&] { shouldExit = false; screen.ExitLoopClosure(); };
|
||||
screen.Loop(menu);
|
||||
|
||||
if (shouldExit) return 0;
|
||||
|
||||
if (selectedExample >= examples.size())
|
||||
if (selectedExample < 0)
|
||||
{
|
||||
throw std::runtime_error("Invalid menu selection!");
|
||||
std::vector<std::string> examples;
|
||||
for (const auto& e : EXAMPLE_APPS)
|
||||
{
|
||||
examples.emplace_back(e.first);
|
||||
}
|
||||
|
||||
ftxui::MenuOption option;
|
||||
auto screen = ftxui::ScreenInteractive::TerminalOutput();
|
||||
bool shouldExit = true;
|
||||
option.on_enter = [&]() { shouldExit = false; screen.ExitLoopClosure()(); };
|
||||
auto menu = ftxui::Menu(&examples, &selectedExample, option);
|
||||
screen.Loop(menu);
|
||||
|
||||
if (shouldExit) return 0;
|
||||
|
||||
if (selectedExample >= examples.size())
|
||||
{
|
||||
throw std::runtime_error("Invalid menu selection!");
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<IGraphicsApp> app(EXAMPLE_APPS[selectedExample].second());
|
||||
|
||||
Reference in New Issue
Block a user