@black-flag/core • Docs
@black-flag/core / index / ConfigurationHooks
ConfigurationHooks:
object
An object containing zero or more configuration hooks. See each hook type definition for details.
optional
configureArguments:ConfigureArguments
This function is called once towards the beginning of the execution of
PreExecutionContext::execute
and should return a process.argv
-like array.
This is where yargs middleware and other argument pre-processing can be implemented.
optional
configureErrorHandlingEpilogue:ConfigureErrorHandlingEpilogue
This function is called once at the very end of the error handling process after an error has occurred.
Note that this function is always called whenever there is an error,
regardless of which other functions have already been called. The only
exceptions to this are if (1) the error occurs within
configureErrorHandlingEpilogue
itself or (2) the error is an instance of
GracefulEarlyExitError
.
This function is also called even after yargs internally handles and reports an argument parsing/validation error.
optional
configureExecutionContext:ConfigureExecutionContext
This function is called once towards the beginning of the execution of
configureProgram
and should return what will become the global
ExecutionContext singleton.
Note that any errors thrown this early in the initialization process will be thrown as-is and will NOT trigger ConfigureErrorHandlingEpilogue.
optional
configureExecutionEpilogue:ConfigureExecutionEpilogue
This function is called once after CLI argument parsing completes and either
(1) handler execution succeeds or (2) a GracefulEarlyExitError
is thrown.
The value returned by this function is used as the return value of the
PreExecutionContext::execute
method. This function will not be called
when yargs argument validation fails.
This function is the complement of ConfigureExecutionPrologue.
optional
configureExecutionPrologue:ConfigureExecutionPrologue
This function is called once towards the end of the execution of
configureProgram
, after all commands have been discovered but before any
have been executed, and should apply any final configurations to the
programs that constitute the command line interface.
All commands and sub-commands known to Black Flag are available in the
ExecutionContext.commands map, which can be accessed from the
context
parameter or from the Arguments object returned by
Program::parseAsync
etc.
This function is the complement of ConfigureExecutionEpilogue.
Note that any errors thrown this early in the initialization process will be thrown as-is and will NOT trigger ConfigureErrorHandlingEpilogue.