Skip to content

Commit

Permalink
Loop
Browse files Browse the repository at this point in the history
  • Loading branch information
huonw committed Nov 4, 2024
1 parent b315920 commit cdc50f1
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions reference_codegen/generate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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-]")
? "<bool>"
: splitFirst(exampleCli, "=")[1];

if (val) {
return val;
// Find the first argument we can understand:
for (const exampleCli of displayArgs) {
const val = exampleCli.includes("[no-]")
? "<bool>"
: 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}`
Expand Down

0 comments on commit cdc50f1

Please sign in to comment.