From 3fc85b79341fb3d5de44e8a9b3924f95f0a07cac Mon Sep 17 00:00:00 2001 From: whitequark Date: Tue, 24 Jan 2017 19:55:53 +0000 Subject: [PATCH] CLI: add the "regenerate" command, for use in Makefiles etc. --- src/platform/climain.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/platform/climain.cpp b/src/platform/climain.cpp index 1eff1ee1..c8cae597 100644 --- a/src/platform/climain.cpp +++ b/src/platform/climain.cpp @@ -46,6 +46,8 @@ static void ShowUsage(const std::string &cmd) { being triangulated first. export-surfaces --output Exports exact surfaces of solids in the sketch, if any. + regenerate + Reloads all imported files, regenerates the sketch, and saves it. )"); auto FormatListFromFileFilter = [](const FileFilter *filter) { @@ -266,6 +268,20 @@ static bool RunCommand(const std::vector args) { StepFileWriter sfw = {}; sfw.ExportSurfacesTo(output); }; + } else if(args[1] == "regenerate") { + for(size_t argn = 2; argn < args.size(); argn++) { + if(!(ParseInputFile(argn))) { + fprintf(stderr, "Unrecognized option '%s'.\n", args[argn].c_str()); + return false; + } + } + + outputPattern = "%.slvs"; + + runner = [&](const std::string &output) { + SS.ReloadAllImported(); + SS.SaveToFile(output); + }; } else { fprintf(stderr, "Unrecognized command '%s'.\n", args[1].c_str()); return false;