@@ -27,8 +27,7 @@ A CLI with an optional command and a couple options:
2727``` typescript
2828import { bargs , opt , pos } from ' @boneskull/bargs' ;
2929
30- await bargs
31- .create (' greet' , { version: ' 1.0.0' })
30+ await bargs (' greet' , { version: ' 1.0.0' })
3231 .globals (
3332 opt .options ({
3433 name: opt .string ({ default: ' world' }),
@@ -112,11 +111,10 @@ const parser = pos.positionals(pos.variadic('string', { name: 'text' }))(
112111 }),
113112);
114113
115- const { values, positionals } = await bargs
116- .create (' echo' , {
117- description: ' Echo text to stdout' ,
118- version: ' 1.0.0' ,
119- })
114+ const { values, positionals } = await bargs (' echo' , {
115+ description: ' Echo text to stdout' ,
116+ version: ' 1.0.0' ,
117+ })
120118 .globals (parser )
121119 .parseAsync ();
122120
@@ -132,11 +130,10 @@ For a CLI with multiple subcommands:
132130``` typescript
133131import { bargs , merge , opt , pos } from ' @boneskull/bargs' ;
134132
135- await bargs
136- .create (' tasks' , {
137- description: ' A task manager' ,
138- version: ' 1.0.0' ,
139- })
133+ await bargs (' tasks' , {
134+ description: ' A task manager' ,
135+ version: ' 1.0.0' ,
136+ })
140137 .globals (
141138 opt .options ({
142139 verbose: opt .boolean ({ aliases: [' v' ], default: false }),
@@ -189,8 +186,7 @@ Commands can be nested to arbitrary depth by passing a `CliBuilder` as the secon
189186import { bargs , opt , pos } from ' @boneskull/bargs' ;
190187
191188// Define subcommands as a separate builder
192- const remoteCommands = bargs
193- .create (' remote' )
189+ const remoteCommands = bargs (' remote' )
194190 .command (
195191 ' add' ,
196192 pos .positionals (
@@ -208,8 +204,7 @@ const remoteCommands = bargs
208204 .defaultCommand (' add' );
209205
210206// Nest under parent CLI
211- await bargs
212- .create (' git' )
207+ await bargs (' git' )
213208 .globals (opt .options ({ verbose: opt .boolean ({ aliases: [' v' ] }) }))
214209 .command (' remote' , remoteCommands , ' Manage remotes' ) // ← CliBuilder
215210 .command (' commit' , commitParser , commitHandler ) // ← Regular command
@@ -227,7 +222,7 @@ Parent globals automatically flow to nested command handlers. You can nest as de
227222
228223## API
229224
230- ### bargs.create (name, options?)
225+ ### bargs(name, options?)
231226
232227Create a CLI builder.
233228
@@ -243,7 +238,7 @@ Create a CLI builder.
243238Set global options and transforms that apply to all commands.
244239
245240``` typescript
246- bargs . create (' my-cli' ).globals (opt .options ({ verbose: opt .boolean () }));
241+ bargs (' my-cli' ).globals (opt .options ({ verbose: opt .boolean () }));
247242// ...
248243```
249244
@@ -268,9 +263,9 @@ Register a command. The handler receives merged global + command types.
268263Register a nested command group. The ` cliBuilder ` is another ` CliBuilder ` whose commands become subcommands. Parent globals are passed down to nested handlers.
269264
270265``` typescript
271- const subCommands = bargs . create (' sub' ).command (' foo' , ... ).command (' bar' , ... );
266+ const subCommands = bargs (' sub' ).command (' foo' , ... ).command (' bar' , ... );
272267
273- bargs . create (' main' )
268+ bargs (' main' )
274269 .command (' nested' , subCommands , ' Nested commands' ) // nested group
275270 .parseAsync ();
276271
@@ -304,11 +299,11 @@ Parse arguments and execute handlers.
304299
305300``` typescript
306301// Async (supports async transforms/handlers)
307- const result = await bargs . create (' my-cli' ).globals (... ).parseAsync ();
302+ const result = await bargs (' my-cli' ).globals (... ).parseAsync ();
308303console .log (result .values , result .positionals , result .command );
309304
310305// Sync (no async transforms/handlers)
311- const result = bargs . create (' my-cli' ).globals (... ).parse ();
306+ const result = bargs (' my-cli' ).globals (... ).parse ();
312307```
313308
314309## Option Helpers
@@ -469,8 +464,7 @@ const globals = map(
469464 }),
470465);
471466
472- await bargs
473- .create (' my-cli' )
467+ await bargs (' my-cli' )
474468 .globals (globals )
475469 .command (
476470 ' info' ,
@@ -513,8 +507,7 @@ If you prefer camelCase property names instead of kebab-case, use the `camelCase
513507``` typescript
514508import { bargs , map , opt , camelCaseValues } from ' @boneskull/bargs' ;
515509
516- const { values } = await bargs
517- .create (' my-cli' )
510+ const { values } = await bargs (' my-cli' )
518511 .globals (
519512 map (
520513 opt .options ({
@@ -542,12 +535,12 @@ By default, **bargs** displays your package's homepage and repository URLs (from
542535
543536``` typescript
544537// Custom epilog
545- bargs . create (' my-cli' , {
538+ bargs (' my-cli' , {
546539 epilog: ' For more info, visit https://example.com' ,
547540});
548541
549542// Disable epilog entirely
550- bargs . create (' my-cli' , { epilog: false });
543+ bargs (' my-cli' , { epilog: false });
551544```
552545
553546## Theming
@@ -556,18 +549,18 @@ Customize help output colors with built-in themes or your own:
556549
557550``` typescript
558551// Use a built-in theme: 'default', 'mono', 'ocean', 'warm'
559- bargs . create (' my-cli' , { theme: ' ocean' });
552+ bargs (' my-cli' , { theme: ' ocean' });
560553
561554// Disable colors entirely
562- bargs . create (' my-cli' , { theme: ' mono' });
555+ bargs (' my-cli' , { theme: ' mono' });
563556```
564557
565558The ` ansi ` export provides common ANSI escape codes for styled terminal output:
566559
567560``` typescript
568561import { ansi } from ' @boneskull/bargs' ;
569562
570- bargs . create (' my-cli' , {
563+ bargs (' my-cli' , {
571564 theme: {
572565 command: ansi .bold ,
573566 flag: ansi .brightCyan ,
@@ -613,7 +606,7 @@ import {
613606} from ' @boneskull/bargs' ;
614607
615608try {
616- await bargs . create (' my-cli' ).parseAsync ();
609+ await bargs (' my-cli' ).parseAsync ();
617610} catch (error ) {
618611 if (error instanceof ValidationError ) {
619612 // Config validation failed (e.g., invalid schema)
0 commit comments