Skip to content

Commit

Permalink
Add parsing life cycle and hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowspawn authored and abetomo committed Apr 7, 2023
1 parent 1aa5271 commit 28928ed
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/parsing-and-hooks.md
@@ -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

0 comments on commit 28928ed

Please sign in to comment.