fix(cli): recognise the --pm long alias when extracting template flags - #280
fix(cli): recognise the --pm long alias when extracting template flags#280latent-9 wants to merge 1 commit into
Conversation
extractTemplateOptionFlags splits argv into known CLI flags and template flags before Commander parses them. Commander stores the alias of a two-long-token option (--pm, --package-manager) in option.short, but findKnownOption only compared --prefixed args against option.long, so --pm was never recognised: it was stripped into templateOptions and its value became a stray positional, leaving the documented "--pm pnpm/yarn" alias broken while --package-manager kept working. hasInlineValue had the same blind spot, matching the inline value against the canonical long, so "--pm=pnpm" followed by a template flag misrouted that flag. Match the arg against option.short as well, and detect the inline value on the arg itself. Adds tests for the space and inline alias forms.
|
Greptile SummaryFixes extraction of Commander options declared with two long tokens so the documented
Confidence Score: 5/5The PR appears safe to merge, with the alias handling covered by focused regression tests and no actionable defects identified. The extraction logic now preserves Commander鈥檚 long alias and correctly treats its inline assignment as self-contained while continuing to route the following template flag separately. Important Files Changed
Reviews (1): Last reviewed commit: "fix(cli): recognise the --pm long alias ..." | Re-trigger Greptile |
commit: |
Summary
The documented
--pmalias for--package-managerdoes not work.create-solana-dapp my-app --pm pnpm(the form shown in the CLI help:--package-manager pnpm # or --pm pnpm/yarn) does not set the package manager, and--pm=pnpmthrows.--package-manageritself works.extractTemplateOptionFlagssplits argv into flags Commander knows and template flags before Commander parses them. For a two-long-token option (--pm, --package-manager <package-manager>), Commander 14 stores the canonical long (--package-manager) inoption.longand the alias (--pm) inoption.short.findKnownOptiononly compares a---prefixed arg againstoption.long, so--pmis not recognised as a known option: it is stripped intotemplateOptionsand its value (pnpm) is left as a stray positional.hasInlineValuehas the same blind spot: it checks the inline value against the canonical long (arg.startsWith(--package-manager=)), so--pm=pnpmis not detected as carrying a value. The parser then preserves the following token, so a template flag written after an inline alias (e.g.--pm=pnpm --ollama) is misrouted into the known argv instead of the template options.Fix
findKnownOption: also match the---arg againstoption.short, where Commander keeps the long alias.hasInlineValue: detect the inline=on the arg itself rather than against the canonical long.Tests
Adds two cases using a command with a
--pm, --package-manageroption: the space form (--pm pnpm) is preserved as a known flag, and the inline form followed by a template flag (--pm=pnpm --ollama) keeps--pm=pnpmin argv and routes--ollamato template options. Both fail before the fix and pass after. The full suite stays green.