@@ -25,7 +25,7 @@ or process lifetime. It is not a CLI parser whose product is a bag of flags. Its
2525product is a typed intent; your application decides what that intent does.
2626
2727``` text
28- input → route → method → required binding and validation → intent
28+ input → bind and expand phases → resolve route + method → intent
2929```
3030
3131## Define every way into the program
@@ -151,9 +151,10 @@ An execute intent has two views of configuration:
151151| ` simulacrum database ` | ` method-not-allowed ` ; ` /database ` does not support execution |
152152| ` simulacrum serve --port nope ` | ` unprocessable-content ` ; invalid data never reaches the application |
153153
154- Command literals are routing tokens, not positional arguments. Configliere
155- selects the route first, then binds options to the route segment that owns them.
156- This makes identical option names on parent and child routes unambiguous.
154+ Command literals are routing tokens, not positional arguments. As route segments
155+ become discoverable, Configliere scopes parameter binding to the segment that
156+ owns each token. This makes identical option names on parent and child routes
157+ unambiguous.
157158
158159## Marshal configuration into the route
159160
@@ -188,9 +189,47 @@ CLI → environment → JavaScript values → schema default
188189
189190## Pause without surrendering the type system
190191
191- Sometimes the route cannot be fully configured— or even fully discovered— until
192+ Sometimes the route cannot be fully configured, or even fully discovered, until
192193the application performs I/O. Configliere can pause at a typed checkpoint and
193- resume with the result:
194+ resume with the result.
195+
196+ Dynamic phases serve two common cases:
197+
198+ - Load a configuration file, then use its contents as value sources for later
199+ parameters.
200+ - Load plugins, then extend the route graph with their options and routes.
201+
202+ ` checkpoint() ` is the configuration-file convenience; ` dynamic() ` is the general
203+ route-extension mechanism. Both keep I/O in the application while preserving the
204+ exact type of what parsing can produce next.
205+
206+ ### Help and version cross checkpoints
207+
208+ ` --help ` and ` --version ` request methods; they do not settle an intent or bypass
209+ parsing. Configliere cannot produce either intent until it knows the deepest
210+ selected route. A dynamic phase may introduce that route, its options, or its
211+ version.
212+
213+ The driver must therefore resume every increment until parsing returns an
214+ intent—even when the arguments contain ` --help ` or ` --version ` . This applies
215+ recursively when one continuation exposes another increment.
216+
217+ ``` text
218+ app --config app.json auth0 --help
219+ → bind the configuration phase
220+ → load configuration and resume
221+ → discover /auth0
222+ → HELP /auth0
223+ ```
224+
225+ Help and version are not escape hatches around configuration loading. Do not
226+ inspect ` argv ` to skip a checkpoint. A phase may be required by ` HELP ` ,
227+ ` VERSION ` , or ` EXECUTE ` , so its driver work must be safe for all three: return
228+ loading and validation failures as ` Result ` issues, avoid command side effects,
229+ and defer execution until an ` EXECUTE ` intent. If discovery fails, report that
230+ failure rather than printing incomplete help for an unresolved route graph.
231+ Routes without dynamic phases still resolve directly; the rule is to stop only
232+ at an intent or failure, never merely because the arguments look informational.
194233
195234``` ts
196235import process from " node:process" ;
@@ -200,14 +239,19 @@ import {
200239 name ,
201240 option ,
202241 parse ,
242+ printErrors ,
243+ printHelp ,
244+ printVersion ,
203245 type Result ,
204246 schema ,
205247 type ValueSource ,
248+ version ,
206249} from " @frontside/configliere" ;
207250import * as z from " zod" ;
208251
209252const app = command (
210253 name (" server" ),
254+ version (" 1.0.0" ),
211255 option (name (" config" ), schema (z .string ())),
212256 checkpoint (),
213257 option (name (" port" ), schema (z .number ())),
@@ -216,6 +260,7 @@ const app = command(
216260const step = parse (app , { argv: process .argv .slice (2 ) });
217261
218262if (! step .ok ) {
263+ console .error (printErrors (step ));
219264 process .exit (1 );
220265}
221266
@@ -224,8 +269,23 @@ step.model.config; // string—the model resolved before the checkpoint
224269const loaded = await load (step .model .config );
225270const result = step .resume (loaded );
226271
227- if (result .ok && result .method === " execute" ) {
228- result .model ; // { config: string; port: number }
272+ if (! result .ok ) {
273+ console .error (printErrors (result ));
274+ process .exit (1 );
275+ }
276+
277+ switch (result .method ) {
278+ case " help" :
279+ console .log (printHelp (result ));
280+ break ;
281+
282+ case " version" :
283+ console .log (printVersion (result ));
284+ break ;
285+
286+ case " execute" :
287+ result .model ; // { config: string; port: number }
288+ break ;
229289}
230290
231291declare function load(path : string ): Promise <Result <ValueSource []>>;
0 commit comments