What
parseFlags in src/cli/index.ts only understands the two-token form --url <value>. The single-token form most CLIs also accept fails with a message that reads like a different problem:
owlsql generate --url=postgres://localhost/db
Error: Missing value for --url=postgres://localhost/db
The parser takes everything after -- as the flag name (url=postgres://localhost/db), looks at the next argv entry for a value, finds none, and throws. The error names a flag that doesn't exist and never hints at the actual issue.
A related edge in the same loop: any value that legitimately starts with -- is rejected by the value.startsWith('--') guard, so there's no way to pass such a value at all.
Fix idea
Split on the first = before the name/value handling:
const eq = name.indexOf('=');
if (eq !== -1) {
flags.set(name.slice(0, eq), name.slice(eq + 1));
continue;
}
That also gives users an escape hatch for values starting with --, which makes the startsWith('--') guard on the two-token form safe to keep as-is.
Acceptance
--url=..., --out=..., --dialect=..., --schema=... all work and mix freely with the spaced form.
--url --weird-value still errors clearly in the spaced form, while --url=--weird-value passes it through.
- A couple of cases in a small unit test for
parseFlags (may need exporting it or extracting it for testability, same pattern as the map*Type functions).
What
parseFlagsinsrc/cli/index.tsonly understands the two-token form--url <value>. The single-token form most CLIs also accept fails with a message that reads like a different problem:The parser takes everything after
--as the flag name (url=postgres://localhost/db), looks at the next argv entry for a value, finds none, and throws. The error names a flag that doesn't exist and never hints at the actual issue.A related edge in the same loop: any value that legitimately starts with
--is rejected by thevalue.startsWith('--')guard, so there's no way to pass such a value at all.Fix idea
Split on the first
=before the name/value handling:That also gives users an escape hatch for values starting with
--, which makes thestartsWith('--')guard on the two-token form safe to keep as-is.Acceptance
--url=...,--out=...,--dialect=...,--schema=...all work and mix freely with the spaced form.--url --weird-valuestill errors clearly in the spaced form, while--url=--weird-valuepasses it through.parseFlags(may need exporting it or extracting it for testability, same pattern as themap*Typefunctions).