From cdc50f1db5a3c7d1559def43e1f59958bb09cb38 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Mon, 4 Nov 2024 16:21:04 +1100 Subject: [PATCH] Loop --- reference_codegen/generate.mjs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/reference_codegen/generate.mjs b/reference_codegen/generate.mjs index 1072d147..4293108a 100644 --- a/reference_codegen/generate.mjs +++ b/reference_codegen/generate.mjs @@ -200,16 +200,18 @@ function splitFirst(string, sep) { /** Return a representation of arg value from the CLI. */ function deduceArgValue(displayArgs, envVar) { - const exampleCli = displayArgs[0]; - - const val = exampleCli.includes("[no-]") - ? "" - : splitFirst(exampleCli, "=")[1]; - - if (val) { - return val; + // Find the first argument we can understand: + for (const exampleCli of displayArgs) { + const val = exampleCli.includes("[no-]") + ? "" + : splitFirst(exampleCli, "=")[1]; + + if (val) { + return val; + } } + // Didn't understand any of the args, flag for the user to help: const args = JSON.stringify(displayArgs); throw new Error( `In ${envVar}, failed to deduce value formatting from example CLI instances: ${args}`