-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1aa5271
commit 28928ed
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Parsing life cycle and hooks | ||
|
||
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. | ||
The final command calls the action handler. | ||
|
||
Starting with top-level command (program): | ||
|
||
- parse options: parse recognised options (for this command) and remove from args | ||
- parse env: look for environment variables (for this command) | ||
- process implied: set any implied option values (for this command) | ||
- if the first arg is a subcommand | ||
- call `preSubcommand` hook | ||
- pass remaining arguments to subcommand, and process same way | ||
|
||
Once reach final (leaf) command: | ||
|
||
- check for missing mandatory options | ||
- check for conflicting options | ||
- check for unknown options | ||
- process remaining args as command-arguments | ||
- call `preAction` hook | ||
- call action handler | ||
- call `postAction` hook |