This commit is contained in:
Richard Ward
2025-12-19 02:21:04 +00:00
parent 9bb09e593f
commit eb95a296ec
2 changed files with 17 additions and 5 deletions

View File

@@ -31,7 +31,7 @@ If you need the Conan runtime environment (e.g., because dependencies set env va
## Runtime configuration
`main.cpp` now uses a JSON-driven entrypoint. Use `sdl3_app --json-file-in <path>` to load a configuration that points at the Lua script and captures window dimensions, or run `sdl3_app --create-seed-json config/seed_runtime.json` to write a starter JSON file (based on the executables `scripts/cube_logic.lua` location). You can also use `sdl3_app --set-default-json` to store the current runtime JSON in the platform default directory (APPDATA on Windows, `XDG_CONFIG_HOME`/`$HOME/.config` elsewhere); when that default file exists, the app will pick it up automatically when launched without extra CLI options. If no JSON input is provided and no default exists, the app falls back to discovering `scripts/cube_logic.lua` next to the binary.
`main.cpp` now uses a JSON-driven entrypoint. Use `sdl3_app --json-file-in <path>` to load a configuration that points at the Lua script and captures window dimensions, or run `sdl3_app --create-seed-json config/seed_runtime.json` to write a starter JSON file (based on the executables `scripts/cube_logic.lua` location). You can also use `sdl3_app --set-default-json` (optionally followed by an existing JSON path) to copy the runtime JSON to the platform default directory (APPDATA on Windows, `XDG_CONFIG_HOME`/`$HOME/.config` elsewhere); when that default file exists, the app picks it up automatically when launched without extra CLI options. If no JSON input is provided and no default exists, the app falls back to discovering `scripts/cube_logic.lua` next to the binary.
## Dependency automation

View File

@@ -136,15 +136,19 @@ struct AppOptions {
AppOptions ParseCommandLine(int argc, char** argv) {
std::string jsonInputText;
std::string seedOutputText;
bool setDefaultJson = false;
std::string setDefaultJsonPath;
CLI::App app("SDL3 + Vulkan runtime helper");
app.add_option("-j,--json-file-in", jsonInputText, "Path to a runtime JSON config")
->check(CLI::ExistingFile);
app.add_option("-s,--create-seed-json", seedOutputText,
"Write a template runtime JSON file");
app.add_flag("--set-default-json", setDefaultJson,
"Persist the runtime JSON to the platform default location (XDG/APPDATA)");
auto* setDefaultJsonOption = app.add_option(
"--set-default-json", setDefaultJsonPath,
"Persist the runtime JSON to the platform default location (XDG/APPDATA); "
"pass a path to copy that JSON");
setDefaultJsonOption->type_name("PATH");
setDefaultJsonOption->type_size(0, 1);
try {
app.parse(argc, argv);
@@ -153,9 +157,17 @@ AppOptions ParseCommandLine(int argc, char** argv) {
throw;
}
bool shouldSaveDefault = setDefaultJsonOption->count() > 0;
std::optional<std::filesystem::path> providedDefaultPath;
if (shouldSaveDefault && !setDefaultJsonPath.empty()) {
providedDefaultPath = std::filesystem::absolute(setDefaultJsonPath);
}
RuntimeConfig runtimeConfig;
if (!jsonInputText.empty()) {
runtimeConfig = LoadRuntimeConfigFromJson(std::filesystem::absolute(jsonInputText));
} else if (providedDefaultPath) {
runtimeConfig = LoadRuntimeConfigFromJson(*providedDefaultPath);
} else if (auto defaultPath = GetDefaultConfigPath();
defaultPath && std::filesystem::exists(*defaultPath)) {
runtimeConfig = LoadRuntimeConfigFromJson(*defaultPath);
@@ -168,7 +180,7 @@ AppOptions ParseCommandLine(int argc, char** argv) {
if (!seedOutputText.empty()) {
options.seedOutput = std::filesystem::absolute(seedOutputText);
}
options.saveDefaultJson = setDefaultJson;
options.saveDefaultJson = shouldSaveDefault;
return options;
}