Skip to content

Commit 438fec7

Browse files
committed
docs: update verbiage to match latest changes
1 parent ee77e0c commit 438fec7

File tree

3 files changed

+137
-112
lines changed

3 files changed

+137
-112
lines changed

docs/bf-vs-yargs.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Flag, but are noted below nonetheless.
4040
`yargs::help`/`yargs::version` will throw. If you require the functionality of
4141
`yargs::help`/`yargs::version` to disable or modify the `--help`/`--version`
4242
option, update
43-
[`context.state.globalHelpOption`][9]/[`context.state.globalVersionOption`][10]
43+
[`ExecutionContext::state.globalHelpOption`][9]/[`ExecutionContext::state.globalVersionOption`][10]
4444
directly in [`configureExecutionContext`][11].
4545

4646
> [!NOTE]
@@ -53,8 +53,8 @@ Flag, but are noted below nonetheless.
5353
> Only the root command support the built-in `--version` option. Calling
5454
> `--version` on a child command will have no effect unless you make it so.
5555
> This dodges [another Yargs footgun][12], and setting
56-
> [`context.state.globalVersionOption = undefined`][10] will prevent Yargs
57-
> from clobbering any custom version arguments on the root command too.
56+
> [`ExecutionContext::state.globalVersionOption = undefined`][10] will prevent
57+
> Yargs from clobbering any custom version arguments on the root command too.
5858
5959
## Irrelevant Differences
6060

@@ -116,12 +116,15 @@ Flag, but are noted below nonetheless.
116116
will throw if invoked more than once.
117117

118118
- One of Black Flag's features is simple comprehensive error reporting via the
119-
[`configureErrorHandlingEpilogue`][24] configuration hook. Therefore, the
120-
`yargs::showHelpOnFail` method will ignore the redundant "message" parameter.
121-
If you want that functionality, use said hook to output an epilogue after
122-
Yargs outputs an error message, or use `yargs::epilogue`/`yargs::example`.
123-
Also, any invocation of `yargs::showHelpOnFail` applies globally to all
124-
commands in your hierarchy.
119+
[`configureErrorHandlingEpilogue`][24] configuration hook. Therefore, Black
120+
Flag's overridden version of the `yargs::showHelpOnFail` method will ignore
121+
the redundant "message" parameter. If you want that functionality, use said
122+
hook to output an epilogue after Yargs outputs an error message, or use
123+
`yargs::epilogue`/`yargs::example`.
124+
125+
Also, any invocation of Black Flag's `yargs::showHelpOnFail` method applies
126+
globally to all commands in your hierarchy; internally, the method is just
127+
updating [`ExecutionContext::state.showHelpOnFail`][25].
125128

126129
- Since every auto-discovered command translates [into its own Yargs
127130
instances][6], the [`command`][17] property, if exported by your command
@@ -153,7 +156,7 @@ Flag, but are noted below nonetheless.
153156
`yargs::parseX` functions directly anyway.
154157

155158
- Black Flag sets several defaults compared to vanilla Yargs. These defaults are
156-
detailed [here][25].
159+
detailed [here][26].
157160

158161
[1]:
159162
https://github.com/jestjs/jest/blob/e7280a2132f454d5939b22c4e9a7a05b30cfcbe6/packages/jest-util/Readme.md#deepcycliccopy
@@ -183,4 +186,6 @@ Flag, but are noted below nonetheless.
183186
[22]: https://github.com/yargs/yargs/issues/1137
184187
[23]: ./api/src/exports/util/type-aliases/PreExecutionContext.md#execute
185188
[24]: ./api/src/exports/type-aliases/ConfigureErrorHandlingEpilogue.md
186-
[25]: ./getting-started.md#building-and-running-your-cli
189+
[25]:
190+
./api/src/exports/util/type-aliases/ExecutionContext.md#stateshowhelponfail
191+
[26]: ./getting-started.md#building-and-running-your-cli

docs/features.md

Lines changed: 61 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,11 @@ const configuration: Configuration = {
280280
export 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

285290
Black Flag not only helps you declaratively build your CLI tool, but _run it_
@@ -305,18 +310,18 @@ myctl remote show origin
305310
deno ./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.
309314
when 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
318323
auto-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
320325
around `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
362367
works out the box with sensible defaults and no sprawling configuration files**.
363368
364369
However, when additional configuration _is_ required, there are five optional
@@ -513,7 +518,7 @@ commands. Specifically:
513518
available).
514519
515520
How 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,
517522
as 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
634639
And for those who prefer a more holistic behavior-driven testing approach, you
635640
can 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
724729
into 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

741746
It 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
743748
improved DX) in your `package.json` dependencies and import it in your command
744749
files:
745750

@@ -800,8 +805,8 @@ However, your command files are not tightly coupled with Black Flag. An
800805
unfortunate side effect of this flexibility is that your command files do not
801806
automatically pick up Black Flag's types in your IDE/editor. Fortunately, Black
802807
Flag 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
806811
Using these types, your command files themselves can be fully typed and you can
807812
enjoy the improved DX that comes with comprehensive intellisense. And for those
@@ -828,23 +833,23 @@ module.exports = {
828833
```
829834
830835
Child 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

840845
Similarly, 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
843848
All of these generic types accept type parameters for validating custom
844849
properties you might set during argument parsing or on the shared execution
845850
context 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
848853
implementation 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
857862
variable). 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
861866
recipes solving common CLI tasks the Black Flag way.
862867

863868
For 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

Comments
 (0)