Skip to content

Commit 28928ed

Browse files
shadowspawnabetomo
authored andcommitted
Add parsing life cycle and hooks
1 parent 1aa5271 commit 28928ed

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/parsing-and-hooks.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Parsing life cycle and hooks
2+
3+
The processing starts with an array of args. Each command processes and removes the options it understands, and passes the remaining args to the next subcommand.
4+
The final command calls the action handler.
5+
6+
Starting with top-level command (program):
7+
8+
- parse options: parse recognised options (for this command) and remove from args
9+
- parse env: look for environment variables (for this command)
10+
- process implied: set any implied option values (for this command)
11+
- if the first arg is a subcommand
12+
- call `preSubcommand` hook
13+
- pass remaining arguments to subcommand, and process same way
14+
15+
Once reach final (leaf) command:
16+
17+
- check for missing mandatory options
18+
- check for conflicting options
19+
- check for unknown options
20+
- process remaining args as command-arguments
21+
- call `preAction` hook
22+
- call action handler
23+
- call `postAction` hook

0 commit comments

Comments
 (0)