Skip to content
Myr

parsing-and-hooks.md

This file

Path

docs/parsing-and-hooks.md

23 lines · 883 bytes · Markdown

Last changed by

Could be multiple hooks, pluraliseJohn Geebefore adoption321cd76

History of this file

Take it

Add parsing life cycle and hooksJohn Geebefore adoption28928ed

lines 1–11why, one step back
1# Parsing life cycle and hooks
23The 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.4The final command calls the action handler.56Starting with top-level command (program):78- parse options: parse recognised options (for this command) and remove from args9- 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

Could be multiple hooks, pluraliseJohn Geebefore adoption321cd76

line 12why, one step back
12 - call `preSubcommand` hooks

Add parsing life cycle and hooksJohn Geebefore adoption28928ed

lines 13–16why, one step back
13 - pass remaining arguments to subcommand, and process same way
1415Once reach final (leaf) command:16

Add new documentation to READMEJohn Geebefore adoption5fbf83a

lines 17–20why, one step back
17- check for missing mandatory options
18- check for conflicting options19- check for unknown options20- process remaining args as command-arguments

Could be multiple hooks, pluraliseJohn Geebefore adoption321cd76

line 21why, one step back
21- call `preAction` hooks

Add new documentation to READMEJohn Geebefore adoption5fbf83a

line 22why, one step back
22- call action handler

Could be multiple hooks, pluraliseJohn Geebefore adoption321cd76

line 23why, one step back
23- call `postAction` hooks