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 fileTake it
Add parsing life cycle and hooksJohn Geebefore adoption28928ed
lines 1–11why, one step back1# Parsing life cycle and hooks23The 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 subcommandCould be multiple hooks, pluraliseJohn Geebefore adoption321cd76
line 12why, one step back12 - call `preSubcommand` hooksAdd parsing life cycle and hooksJohn Geebefore adoption28928ed
lines 13–16why, one step back13 - pass remaining arguments to subcommand, and process same way1415Once reach final (leaf) command:16Add new documentation to READMEJohn Geebefore adoption5fbf83a
lines 17–20why, one step back17- check for missing mandatory options18- check for conflicting options19- check for unknown options20- process remaining args as command-argumentsCould be multiple hooks, pluraliseJohn Geebefore adoption321cd76
line 21why, one step back21- call `preAction` hooksAdd new documentation to READMEJohn Geebefore adoption5fbf83a
line 22why, one step back22- call action handlerCould be multiple hooks, pluraliseJohn Geebefore adoption321cd76
line 23why, one step back23- call `postAction` hooks