Repository navigation
feat(cli): v1 spec surface — ArgSpec, option upgrades, subcommand trees, runAsync - #47
Merged
Merged
Conversation
…bcommand trees, runAsync ArgSpec positionals (optional/variadic/schema'd, ArgsFromSpec tuple typing via const generics), OptionSpec gains optionalValue/variadic/ negatable/env/hidden + camelCase opts keys, commands nest recursively with aliases and a help pseudo-command, ProgramSpec is a root command node (program-level args/options/handler), runAsync awaits Promise- returning handlers and validators. One descent loop drives all levels; the program IS a command node.
Reframe 'Divergences from commander' as 'Migrating from commander', document the v1 surface (arg/option specs, trees, runAsync), record the measured bench numbers and the new subset traps (cast-copy on record-read arrays, ProgramSpec dynamic-slot casts, SC9001 dist-JS nullT, in-repo src imports).
Deploying cutilsjs with
|
| Latest commit: |
9dfa6f2
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://b8e4d259.cutilsjs.pages.dev |
| Branch Preview URL: | https://feat-cli-v1-commander-parity.cutilsjs.pages.dev |
Perf + build-speed release: callback signature-adapter elimination, typed-array conversion, typed Error ctor (smaller exes), non-ASCII regex/slice fast paths, startup layout, Math.random, capture-by-value; build-side: cached frontend, emit-lowered/from-lowered, npm-static diagnostics off. New lowerings incl. named process.* imports, fs Dir + dispose, enum runtime objects, Object.freeze partial views, workspace- pkg bare-import JS compile. All gates 100%, cli ELF smoke green (18 new checked-dynamic warnings to triage later).
scriptc 0.4.10's smaller typed-Error lowering leaves Error.toString undeclared on the %dyn.class.protocol dispatch path, so calling ins.toString() through the Stmt<TRow> interface hits SC9001 in the ELF build. Upcasting to InstanceType<typeof Stmt> (= StmtCore) gives static dispatch; the gate keeps its toString coverage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes the commander-parity gaps called out after the 0.6.0 release, all probe-verified under scriptc 0.4.7 (942 statements, 100% static, zero dynamic slots):
{optional, variadic, default, description, schema}— optional absent →defaultelsenull(neverundefined); variadic (last only) collects into an array slot; schemas validate per element.ArgsFromSpecmaps theargsliteral to a typed tuple viaconstgenerics; plainstring[]annotations keep the legacy shape.optionalValue(--optbare →true,--opt=v→"v"),variadic(--tag a band--tag a --tag b→ per-element schema →O[]),negatable(--no-x→false),env(process.env fallback throughvalidate()),hidden, and kebab-case → camelCaseoptskeys ("template-engine"→opts.templateEngine, commander parity).commandsnests insidecommand()specs — recursive runtime descent (not type-encoded, per the plan doc's rationale). Options before a subcommand token bind the parent; parent opts/args/schema validate before descent.alias(shown asname|alias),hidden,prog help <path…>.ProgramSpeccarries the sameargs/options/schema/handler/commands— single-command CLIs need no wrapper command, and programs can mix root options with dispatch.runAsync: awaits Promise-returning handlers AND Promise-returning Standard-Schema validators;runkeeps both as clean errors.handler: (opts, args) => unknownavoids thevoid | Promise<void>union's dynamic slots.Benchmarks (bench/apps — new workspace,
bench/*glob + scriptc-gates)ELF sizes: argv-baseline 375,888 B → cli-basic 793,640 (+418 KB) → cli-full 980,216 (+604 KB).
Test plan
Notes
## Migrating from commanderreplaces## Divergences.as T[]on a record-read array copies under scriptc — mutate-then-store (pushVar), never cast-and-mutate. Caught by ELF smoke, invisible to coverage.nullTwhen scriptc consumes the dist JS — in-repo apps importsrc/index.ts; the npm./elfconsumer entry is a documented TODO (mirror packages/sqlite)..a, sqlite-Bsymbolic— green in CI).Generated with Devin