You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-9Lines changed: 28 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -453,7 +453,7 @@ _Cleye_ uses all information provided to generate rich help documentation. The m
453
453
#### Help customization
454
454
The help document can be customized by passing a `render(nodes, renderers) => string` function to `help.render`.
455
455
456
-
The `nodes` parameter contains an array of nodes that will be used to render the document. The `renderers` parameter is an object of functions used to render the document. Each node has properties `type` and `data`, where `type` corresponds to a property in `renderers` and `data` is passed into the render function.
456
+
The `nodes` parameter contains an array of nodes that will be used to render the document. The `renderers` parameter is an object of functions used to render the document. Each node has properties `type` and `data`, where `type` corresponds to a property in `renderers` and `data` is passed into the render function. Nodes also have an `id` property to identify sections: `name`, `description`, `usage`, `commands`, `flags`, `examples`, and `aliases`.
457
457
458
458
Default renderers can be found in [`/src/render-help/renderers.ts`](/src/render-help/renderers.ts).
459
459
@@ -521,8 +521,8 @@ type ParsedArgv = {
521
521
// Method to print version
522
522
showVersion: () =>void
523
523
524
-
// Method to print help
525
-
showHelp: (options:HelpOptions) =>void
524
+
// Method to print help (pass HelpOptions to override content)
525
+
showHelp: (options?:HelpOptions) =>void
526
526
}
527
527
```
528
528
@@ -581,7 +581,7 @@ Type: `false` or an object with the following properties.
581
581
| - | - | - |
582
582
| `version` | `string` | Version shown in `--help`. |
583
583
| `description` | `string` | Description shown in `--help`. |
| `usage` | `string \|string[] \|false` | Usage code examples shown in `--help`. Pass `false` to disable auto-generated usage. |
585
585
| `examples` | `string \|string[]` | Example code snippets shown in `--help`. |
586
586
| `render` | `(nodes, renderers) =>string` | Function to customize the help document. |
587
587
@@ -606,11 +606,17 @@ type IgnoreArgvCallback = (
606
606
607
607
A callback to ignore argv tokens from being parsed.
608
608
609
+
##### strictFlags
610
+
611
+
Type: `boolean`
612
+
613
+
When enabled, prints an error and exits if unknown flags are passed. Suggests the closest matching flag name when possible. See [Strict flags](#strict-flags).
614
+
609
615
#### callback(parsed)
610
616
611
-
Type:
617
+
Type:
612
618
613
-
Optional callback function that is called when the script is invoked without a command.
619
+
Optional callback function that is called when the script is invoked without a command. If the callback returns a Promise, the `cli()` return value will also be a Promise, allowing `awaitcli(...)` for async workflows.
614
620
615
621
#### argvs
616
622
@@ -627,16 +633,29 @@ The raw parameters array to parse.
627
633
| Property | Type | Description |
628
634
| - | - | - |
629
635
| `name` | `string` | Required name used to invoke the command. |
630
-
| `alias` | `string \|string[]` | Aliases used to invoke the command. |
636
+
| `alias` | `string \|string[]` | Aliases used to invoke the command. Displayed in an "Aliases:" section in `--help`. |
631
637
| `parameters` | `string[]` | Parameters for the command. Same as [`parameters`](#parameters-1). |
632
638
| `flags` | `Flags` | Flags for the command. Same as [`flags`](#flags-1). |
633
639
| `help` | `false \|HelpOptions` | Help options for the command. Same as [`help`](#help-1). |
640
+
| `ignoreArgv` | `IgnoreArgvCallback` | Same as [`ignoreArgv`](#ignoreargv). |
641
+
| `strictFlags` | `boolean` | Same as [`strictFlags`](#strictflags). Inherits from parent CLI if not specified. |
634
642
635
643
#### callback(parsed)
636
644
637
-
Type:
645
+
Type:
646
+
647
+
Optional callback function that is called when the command is invoked. If the callback returns a Promise, the `cli()` return value will also be a Promise.
648
+
649
+
### Type exports
650
+
The following types are exported for use in TypeScript:
0 commit comments