Skip to content

Commit

Permalink
Make command line help easier to understand (#968)
Browse files Browse the repository at this point in the history
* Rework command line output
Add a new exit code when no sample is selcted or found
Only show a few hint lines with easy to understand help instead of full help

* Spelling and wording
  • Loading branch information
SaschaWillems authored Mar 11, 2024
1 parent f297e6a commit d13cf6c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
20 changes: 16 additions & 4 deletions framework/platform/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ ExitCode Platform::initialize(const std::vector<Plugin *> &plugins)

if (!app_requested())
{
LOGE("An app was not requested, can not continue");
return ExitCode::Help;
return ExitCode::NoSample;
}

create_window(window_properties);
Expand All @@ -137,8 +136,7 @@ ExitCode Platform::main_loop()
{
if (!app_requested())
{
LOGE("An app was not requested, can not continue");
return ExitCode::Close;
return ExitCode::NoSample;
}

while (!window->should_close() && !close_requested)
Expand Down Expand Up @@ -237,6 +235,20 @@ void Platform::terminate(ExitCode code)
}
}

if (code == ExitCode::NoSample)
{
LOGI("");
LOGI("No sample was requested or the selected sample does not exist");
LOGI("");
LOGI("To run a specific sample use the \"sample\" argument, e.g.");
LOGI("");
LOGI("\tvulkan_samples sample hello_triangle");
LOGI("");
LOGI("To get a list of available samples, use the \"samples\" argument")
LOGI("To get a list of available command line options, use the \"-h\" or \"--help\" argument");
LOGI("");
}

if (active_app)
{
std::string id = active_app->get_name();
Expand Down
1 change: 1 addition & 0 deletions framework/platform/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ namespace vkb
enum class ExitCode
{
Success = 0, /* App executed as expected */
NoSample, /* App should show help how to run a sample */
Help, /* App should show help */
Close, /* App has been requested to close at initialization */
FatalError /* App encountered an unexpected error */
Expand Down

0 comments on commit d13cf6c

Please sign in to comment.