From cbe3996e753e6abb7024c8b0007740e9890e1746 Mon Sep 17 00:00:00 2001 From: haanhvu Date: Tue, 20 Feb 2024 23:15:45 +0700 Subject: [PATCH] Add option to write metadata to output --- internal/worker/command_blender.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/internal/worker/command_blender.go b/internal/worker/command_blender.go index 9895e8b5..1baea124 100644 --- a/internal/worker/command_blender.go +++ b/internal/worker/command_blender.go @@ -8,6 +8,7 @@ import ( "context" "os/exec" "regexp" + "slices" "sync" "github.com/google/shlex" @@ -20,6 +21,8 @@ import ( var regexpFileSaved = regexp.MustCompile("Saved: '(.*)'") +var writeMetadataToOutput = false + type BlenderParameters struct { exe string // Expansion of `{blender}`: the executable path defined by the Manager. exeArgs string // Expansion of `{blenderargs}`: its CLI parameters defined by the Manager. @@ -51,6 +54,10 @@ func (ce *CommandExecutor) cmdBlenderRender(ctx context.Context, logger zerolog. } }() + if writeMetadataToOutput { + lineChannel <- "Task ID: " + taskID + } + // Run the subprocess. subprocessErr := ce.cli.RunWithTextOutput(ctx, logger, @@ -141,6 +148,10 @@ func cmdBlenderRenderParams(logger zerolog.Logger, cmd api.Command) (BlenderPara return parameters, NewParameterInvalidError("args", cmd, "cannot convert to list of strings") } + if slices.Contains(parameters.args, "--write-metadata-to-output") { + writeMetadataToOutput = true + } + // Split the exeArgs string into separate parts, and prepend them to `argsBefore`. exeArgs, err := shlex.Split(parameters.exeArgs) if err != nil { -- 2.30.2