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
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -586,6 +586,26 @@ new CliCommand('build')
586
586
}})
587
587
```
588
588
589
+
#### Call order of onProcess() hooks
590
+
The `onProcess()` hooks are called strictly in the order they are assigned to a command, regardless of whether they are assigned on arguments or options.
591
+
This is useful for handling inter-dependencies between `onProcess()` calls. For example:
592
+
593
+
```typescript
594
+
awaitnewCliCommand('call-order')
595
+
.withOptions({ name: ['-f', '--first'], onProcess: (value) => { console.log(`--first with value ${value}`) } })
.withOptions({ name: ['-t', '--third'], onProcess: (value) => { console.log(`--third with value ${value}`) } })
598
+
.withHandler(() => { })
599
+
```
600
+
601
+
```bash
602
+
$call-order"This should be second" --first
603
+
604
+
--firstwithvaluetrue
605
+
secondwithvalueThisshouldbesecond
606
+
--thirdwithvalueundefined
607
+
```
608
+
589
609
## Generating documentation
590
610
The `CliCommand.dump()` method dumps the entire command (and its subcommands) to an easily readable object of type `CommandDefinition`. This is useful for generating documentation.
0 commit comments