Add app id as first cli parameter
This commit is contained in:
@@ -20,18 +20,24 @@ 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)
|
||||||
{
|
{
|
||||||
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());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user