@@ -280,6 +280,11 @@ const configuration: Configuration = {
280280export default configuration ;
281281```
282282
283+ > [ !TIP]
284+ >
285+ > The Yargs DSL for declaring and defining positional parameters is described
286+ > in-depth [ here] [ 14 ] .
287+
283288## Run Your Tool Safely and Consistently ✨
284289
285290Black Flag not only helps you declaratively build your CLI tool, but _ run it_
@@ -305,18 +310,18 @@ myctl remote show origin
305310deno ./cli.ts -- remote show origin
306311```
307312
308- The [ ` runProgram ` ] [ 14 ] function bootstraps your CLI whenever you need it, e.g.
313+ The [ ` runProgram ` ] [ 15 ] function bootstraps your CLI whenever you need it, e.g.
309314when testing, in production, when importing your CLI as a dependency, etc.
310315
311316> [ !IMPORTANT]
312317>
313318> <ins >** ` runProgram ` never throws** </ins >, and never calls ` process.exit ` since
314- > that's [ dangerous] [ 15 ] . When testing your CLI, [ prefer ` makeRunner ` ] [ 16 ]
319+ > that's [ dangerous] [ 16 ] . When testing your CLI, [ prefer ` makeRunner ` ] [ 17 ]
315320> which can be made to throw.
316321
317- Under the hood, ` runProgram ` calls [ ` configureProgram ` ] [ 17 ] , which
322+ Under the hood, ` runProgram ` calls [ ` configureProgram ` ] [ 18 ] , which
318323auto-discovers and collects all the configurations exported from your command
319- files, followed by [ ` PreExecutionContext::execute ` ] [ 18 ] , which is a wrapper
324+ files, followed by [ ` PreExecutionContext::execute ` ] [ 19 ] , which is a wrapper
320325around ` yargs::parseAsync ` and ` yargs::hideBin ` .
321326
322327``` javascript
@@ -358,7 +363,7 @@ export default parsedArgv;
358363
359364## Convention over Configuration ✨
360365
361- Black Flag [favors convention over configuration][19 ], meaning **everything
366+ Black Flag [favors convention over configuration][20 ], meaning **everything
362367works out the box with sensible defaults and no sprawling configuration files**.
363368
364369However, when additional configuration _is_ required, there are five optional
@@ -513,7 +518,7 @@ commands. Specifically:
513518 available).
514519
515520How errors thrown during execution are reported to the user is determined by the
516- optionally-provided [` configureErrorHandlingEpilogue` ][20 ] configuration hook,
521+ optionally-provided [` configureErrorHandlingEpilogue` ][21 ] configuration hook,
517522as well as each command file's optionally-exported [` builder` ][7] function.
518523
519524` ` ` typescript
@@ -538,16 +543,16 @@ export function builder(blackFlag) {
538543
539544> [!TIP]
540545>
541- > [Framework errors][21 ] and errors thrown in ` configureExecutionContext` or
546+ > [Framework errors][22 ] and errors thrown in ` configureExecutionContext` or
542547> ` configureExecutionPrologue` , cannot be handled by
543548> ` configureErrorHandlingEpilogue` .
544549>
545- > If you're using [` makeRunner` ][22 ]/[` runProgram` ][14 ] and a misconfiguration
550+ > If you're using [` makeRunner` ][23 ]/[` runProgram` ][15 ] and a misconfiguration
546551> triggers a framework error, your application will set its exit code
547- > [accordingly][23 ] and send an error message to stderr. If this occurs in
548- > production, use [debug mode][24 ] to gain insight into what went wrong. In a
549- > development environment and/or during testing, [` makeRunner` ][22 ] (below)
550- > supports the [` errorHandlingBehavior` ][25 ] option, which can be used to
552+ > [accordingly][24 ] and send an error message to stderr. If this occurs in
553+ > production, use [debug mode][25 ] to gain insight into what went wrong. In a
554+ > development environment and/or during testing, [` makeRunner` ][23 ] (below)
555+ > supports the [` errorHandlingBehavior` ][26 ] option, which can be used to
551556> surface thrown errors via rejection.
552557
553558## A Pleasant Testing Experience ✨
@@ -633,16 +638,16 @@ test('configureErrorHandlingEpilogue outputs as expected', async () => {
633638
634639And for those who prefer a more holistic behavior-driven testing approach, you
635640can use the same function for testing your CLI that you use as an entry point in
636- production: [` runProgram` ][14 ].
641+ production: [` runProgram` ][15 ].
637642
638643> [!TIP]
639644>
640- > Black Flag provides the [` makeRunner` ][22 ] utility function so you don't have
645+ > Black Flag provides the [` makeRunner` ][23 ] utility function so you don't have
641646> to tediously copy and paste ` runProgram (... )` and all its arguments between
642647> tests.
643648>
644- > Additionally, unlike ` runProgram` , [` makeRunner` ][22 ] can be [configured to
645- > throw any errors][25 ] after [` configureErrorHandlingEpilogue` ][20 ] runs. This
649+ > Additionally, unlike ` runProgram` , [` makeRunner` ][23 ] can be [configured to
650+ > throw any errors][26 ] after [` configureErrorHandlingEpilogue` ][21 ] runs. This
646651> can be useful for more test-driven approaches.
647652
648653` ` ` typescript
@@ -720,9 +725,9 @@ it('throws on bad init --lang arguments', async () => {
720725
721726## Built-In ` debug` Integration for Runtime Insights ✨
722727
723- Black Flag integrates ` debug` (via [rejoinder][26 ]), allowing for deep insight
728+ Black Flag integrates ` debug` (via [rejoinder][27 ]), allowing for deep insight
724729into your tool's runtime without significant overhead or code changes. Simply
725- set the ` DEBUG ` environment variable to an [appropriate value][27 ]:
730+ set the ` DEBUG ` environment variable to an [appropriate value][28 ]:
726731
727732` ` ` shell
728733# Shows all possible debug output
@@ -739,7 +744,7 @@ DEBUG='myctl*' myctl
739744> framework- related issues.
740745
741746It is also possible to get meaningful debug output from your commands
742- themselves . Just include the [debug][28 ] package (or [rejoinder][26 ] for
747+ themselves . Just include the [debug][29 ] package (or [rejoinder][27 ] for
743748improved DX ) in your ` package.json` dependencies and import it in your command
744749files:
745750
@@ -800,8 +805,8 @@ However, your command files are not tightly coupled with Black Flag. An
800805unfortunate side effect of this flexibility is that your command files do not
801806automatically pick up Black Flag' s types in your IDE/editor. Fortunately, Black
802807Flag exports all its exposed types, including the generic
803- [`RootConfiguration`][29 ], [`ParentConfiguration`][30 ], and
804- [`ChildConfiguration`][31 ] types.
808+ [`RootConfiguration`][30 ], [`ParentConfiguration`][31 ], and
809+ [`ChildConfiguration`][32 ] types.
805810
806811Using these types, your command files themselves can be fully typed and you can
807812enjoy the improved DX that comes with comprehensive intellisense. And for those
@@ -828,23 +833,23 @@ module.exports = {
828833```
829834
830835Child commands (commands not declared in index files) should use
831- [`ChildConfiguration`][31 ]. Parent commands (commands declared in index files)
832- should use [`ParentConfiguration`][30 ]. The root parent command (at the apex of
833- the directory storing your command files) should use [`RootConfiguration`][29 ].
836+ [`ChildConfiguration`][32 ]. Parent commands (commands declared in index files)
837+ should use [`ParentConfiguration`][31 ]. The root parent command (at the apex of
838+ the directory storing your command files) should use [`RootConfiguration`][30 ].
834839
835840> [!TIP]
836841>
837- > There' s also [` Configuration` ][32 ], the supertype of the three
842+ > There' s also [` Configuration` ][33 ], the supertype of the three
838843> ` XConfiguration` subtypes.
839844
840845Similarly, if you' re using configuration hooks in a separate file, you can enjoy
841- intellisense with those as well using the [`ConfigureX` generic types][33 ].
846+ intellisense with those as well using the [`ConfigureX` generic types][34 ].
842847
843848All of these generic types accept type parameters for validating custom
844849properties you might set during argument parsing or on the shared execution
845850context object.
846851
847- See [`docs/api/`][34 ] for a complete list of Black Flag' s exports and
852+ See [`docs/api/`][35 ] for a complete list of Black Flag' s exports and
848853implementation details about Black Flag' s various generics.
849854
850855---
@@ -855,13 +860,13 @@ Check out the fully-functional demo repository for that snazzy `myctl` tool
855860[here][5]. Or play with the real thing on NPM:
856861`npx -p @black-flag/demo myctl --help` (also supports `DEBUG` environment
857862variable). Or build the real thing from scratch by following [the complete
858- step-by-step getting started guide][35 ].
863+ step-by-step getting started guide][36 ].
859864
860- There' s also the [` examples/` ][36 ] directory, which houses a collection of
865+ There' s also the [` examples/` ][37 ] directory, which houses a collection of
861866recipes solving common CLI tasks the Black Flag way.
862867
863868For an example of a production CLI tool that puts Black Flag through its paces,
864- check out the source code for my " meta" project: [` @-xun/symbiote` ][37 ].
869+ check out the source code for my " meta" project: [` @-xun/symbiote` ][38 ].
865870
866871[1 ]: https: // github.com/yargs/yargs/issues/793
867872[2 ]: https: // yargs.js.org/docs
@@ -876,29 +881,31 @@ check out the source code for my "meta" project: [`@-xun/symbiote`][37].
876881[11 ]: ./ api/ src/ exports / type- aliases/ Configuration .md #handler
877882[12 ]: ./ api/ src/ exports / type- aliases/ Configuration .md #name
878883[13 ]: ./ api/ src/ exports / type- aliases/ Configuration .md #usage
879- [14 ]: ./ api/ src/ exports / functions/ runProgram .md
880- [15 ]:
884+ [14 ]:
885+ https: // github.com/yargs/yargs/blob/main/docs/advanced.md#positional-arguments
886+ [15 ]: ./ api/ src/ exports / functions/ runProgram .md
887+ [16 ]:
881888 https: // kostasbariotis.com/why-you-should-not-use-process-exit#what-should-we-do
882- [16 ]: #a- pleasant- testing- experience-
883- [17 ]: ./ api/ src/ exports / functions/ configureProgram .md
884- [18 ]: ./ api/ src/ exports / util/ type- aliases/ PreExecutionContext .md #execute
885- [19 ]: https: // en.wikipedia.org/wiki/Convention_over_configuration
886- [20 ]: ./ api/ src/ exports / type- aliases/ ConfigureErrorHandlingEpilogue .md
887- [21 ]: ./ api/ src/ exports / util/ classes/ AssertionFailedError .md
888- [22 ]: ./ api/ src/ exports / util/ functions/ makeRunner .md
889- [23 ]: ./ api/ src/ exports / enumerations/ FrameworkExitCode .md
890- [24 ]: #built- in - debug- integration- for - runtime- insights-
891- [25 ]:
889+ [17 ]: #a- pleasant- testing- experience-
890+ [18 ]: ./ api/ src/ exports / functions/ configureProgram .md
891+ [19 ]: ./ api/ src/ exports / util/ type- aliases/ PreExecutionContext .md #execute
892+ [20 ]: https: // en.wikipedia.org/wiki/Convention_over_configuration
893+ [21 ]: ./ api/ src/ exports / type- aliases/ ConfigureErrorHandlingEpilogue .md
894+ [22 ]: ./ api/ src/ exports / util/ classes/ AssertionFailedError .md
895+ [23 ]: ./ api/ src/ exports / util/ functions/ makeRunner .md
896+ [24 ]: ./ api/ src/ exports / enumerations/ FrameworkExitCode .md
897+ [25 ]: #built- in - debug- integration- for - runtime- insights-
898+ [26 ]:
892899 ./ api/ src/ exports / util/ type- aliases/ MakeRunnerOptions .md #errorhandlingbehavior
893- [26 ]: https: // npm.im/rejoinder
894- [27 ]: https: // www.npmjs.com/package/debug#usage
895- [28 ]: https: // www.npmjs.com/package/debug
896- [29 ]: ./ api/ src/ exports / type- aliases/ RootConfiguration .md
897- [30 ]: ./ api/ src/ exports / type- aliases/ ParentConfiguration .md
898- [31 ]: ./ api/ src/ exports / type- aliases/ ChildConfiguration .md
899- [32 ]: ./ api/ src/ exports / type- aliases/ Configuration .md
900- [33 ]: ./ api/ src/ exports / type- aliases/ ConfigurationHooks .md
901- [34 ]: ./ api/ README .md
902- [35 ]: ./ getting- started .md #building- and- running- your- cli
903- [36 ]: ../ examples/ README .md
904- [37 ]: https: // github.com/Xunnamius/symbiote/blob/main/src
900+ [27 ]: https: // npm.im/rejoinder
901+ [28 ]: https: // www.npmjs.com/package/debug#usage
902+ [29 ]: https: // www.npmjs.com/package/debug
903+ [30 ]: ./ api/ src/ exports / type- aliases/ RootConfiguration .md
904+ [31 ]: ./ api/ src/ exports / type- aliases/ ParentConfiguration .md
905+ [32 ]: ./ api/ src/ exports / type- aliases/ ChildConfiguration .md
906+ [33 ]: ./ api/ src/ exports / type- aliases/ Configuration .md
907+ [34 ]: ./ api/ src/ exports / type- aliases/ ConfigurationHooks .md
908+ [35 ]: ./ api/ README .md
909+ [36 ]: ./ getting- started .md #building- and- running- your- cli
910+ [37 ]: ../ examples/ README .md
911+ [38 ]: https: // github.com/Xunnamius/symbiote/blob/main/src
0 commit comments