From 627cae93a1a6201410facb7409d3dc6529cc6f0d Mon Sep 17 00:00:00 2001 From: Dan Rosser Date: Sat, 31 Oct 2026 14:31:38 +1100 Subject: [PATCH 1/2] CLI: take option values given as -p osx / --platforms osx, fail on two project paths or the OF folder as the project --- commandLine/src/main.cpp | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/commandLine/src/main.cpp b/commandLine/src/main.cpp index 883d94f9..9737ae2a 100644 --- a/commandLine/src/main.cpp +++ b/commandLine/src/main.cpp @@ -65,7 +65,7 @@ constexpr option::Descriptor usage[] = { { FRAMEWORKS, 0, "f", "frameworks", option::Arg::Optional, " --frameworks, -f \tApple system frameworks (such as Security,CoreBluetooth), saved in config.make PROJECT_FRAMEWORKS. Empty removes them" }, { SYSTEMLIBS, 0, "", "system-libs", option::Arg::Optional, " --system-libs \tApple system libraries (such as sqlite3,z = libsqlite3.tbd, libz.tbd), saved in config.make PROJECT_SYSTEM_LIBS. Empty removes them" }, - { CLEANNAME_DISABLE, 0, "n", "cleanname", option::Arg::Optional, " --cleanname, -f \tcleanname" }, + { CLEANNAME_DISABLE, 0, "n", "cleanname", option::Arg::Optional, " --cleanname, -n \tcleanname" }, { DEFINES, 0, "D", "defines", option::Arg::Optional, " --defines, -D \tpreprocessor defines list (such as OF_USE_ANGLE=1,MY_FLAG)" }, { POSTBUILD, 0, "P", "postbuild", option::Arg::Optional, " --postbuild, -P \tscript to run after the project compiles (Xcode run script / VS post-build event)" }, @@ -472,6 +472,29 @@ int pgMain(int argc, char ** argv) { // ------------------------------------------------------ parse args argc -= (argc > 0); argv += (argc > 0); // skip program name argv[0] if present + + // optionparser only takes attached values (-posx, --platforms=osx); join -p osx / --platforms osx, + // but leave the last argument as the project path (-f is an empty -f) + static const std::string valueShort { "paotsmfDPkW" }; + static const std::vector valueLong { "platforms", "addons", "ofPath", "template", "source", "ofmenu", "frameworks", "system-libs", "defines", "postbuild", "msys2env", "emscripten-wasm", "app-version", "app-build" }; + std::vector joinedArgs; + for (int i = 0; i < argc; i++) { + std::string a { argv[i] }; + bool isValueOption = (a.size() == 2 && a[0] == '-' && valueShort.find(a[1]) != std::string::npos) + || (a.rfind("--", 0) == 0 && std::find(valueLong.begin(), valueLong.end(), a.substr(2)) != valueLong.end()); + bool keyword = a == "-m" || a == "--ofmenu"; // status / update-libs, no project path after it + if (isValueOption && i + 1 < argc && argv[i + 1][0] != '-' && (i + 2 < argc || keyword)) { + joinedArgs.emplace_back(a + (a.size() == 2 ? "" : "=") + argv[i + 1]); + i++; + } else { + joinedArgs.emplace_back(a); + } + } + std::vector joinedArgv; + for (auto & a : joinedArgs) joinedArgv.emplace_back(a.data()); + argc = (int)joinedArgv.size(); + argv = joinedArgv.data(); + option::Stats stats(usage, argc, argv); vector options(stats.options_max); vector buffer(stats.buffer_max); @@ -679,6 +702,13 @@ int pgMain(int argc, char ** argv) { if (parse.nonOptionsCount() > 0) { projectName = parse.nonOption(0); } + // a value the parser didn't take (e.g. -n osx) would silently become the project path + if (parse.nonOptionsCount() > 1) { + std::string extra; + for (int i = 0; i < parse.nonOptionsCount(); i++) extra += std::string(i ? ", " : "") + parse.nonOption(i); + messageError("More than one project path: " + extra + " - give option values as -posx / --platforms=osx or -p osx"); + return EXIT_USAGE; + } // ------------------------------------------------------ post parse @@ -738,6 +768,10 @@ int pgMain(int argc, char ** argv) { messageError( "Invalid project path: {" + projectPath.string() + "}"); return EXIT_FAILURE; } + if (!getOFRoot().empty() && fs::weakly_canonical(projectPath) == fs::weakly_canonical(getOFRoot())) { + messageError("The project path is the openFrameworks folder: " + projectPath.string()); + return EXIT_USAGE; + } // make folder if (!fs::exists(projectPath)) { try { From e7bee02a493dd673cb7a9dd9a79e6166d859fc4a Mon Sep 17 00:00:00 2001 From: Dan Rosser Date: Sat, 31 Oct 2026 14:31:38 +1100 Subject: [PATCH 2/2] Updated cmdLine from 0.119.0 to 0.120.0 and PG GUI from 0.113.0 to 0.114.0 --- commandLine/src/defines.h | 2 +- frontend/npm-shrinkwrap.json | 4 ++-- frontend/package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/commandLine/src/defines.h b/commandLine/src/defines.h index 0914405f..7988f49e 100644 --- a/commandLine/src/defines.h +++ b/commandLine/src/defines.h @@ -1,5 +1,5 @@ #define OFPROJECTGENERATOR_MAJOR_VERSION "0" -#define OFPROJECTGENERATOR_MINOR_VERSION "119" +#define OFPROJECTGENERATOR_MINOR_VERSION "120" #define OFPROJECTGENERATOR_PATCH_VERSION "0" #define PG_VERSION (OFPROJECTGENERATOR_MAJOR_VERSION "." OFPROJECTGENERATOR_MINOR_VERSION "." OFPROJECTGENERATOR_PATCH_VERSION) diff --git a/frontend/npm-shrinkwrap.json b/frontend/npm-shrinkwrap.json index ba9313ac..7fca9389 100644 --- a/frontend/npm-shrinkwrap.json +++ b/frontend/npm-shrinkwrap.json @@ -1,12 +1,12 @@ { "name": "projectGenerator", - "version": "0.113.0", + "version": "0.114.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "projectGenerator", - "version": "0.113.0", + "version": "0.114.0", "license": "MIT", "dependencies": { "@types/jquery": "^3.5.34", diff --git a/frontend/package.json b/frontend/package.json index 2c585b66..a8380a67 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "projectGenerator", "productName": "projectGenerator", - "version": "0.113.0", + "version": "0.114.0", "description": "Build electron GUI openFrameworks projectGenerator", "license": "MIT", "main": "index.js",