@black-flag/core • Docs
@black-flag/core / util / PreExecutionContext
PreExecutionContext<
CustomContext
>:CustomContext
&object
Represents the pre-execution context that is the result of calling
configureProgram
.
execute:
Executor
Execute the root command, parsing any available CLI arguments and running the appropriate handler, and return the resulting final parsed arguments object.
This function throws whenever* an exception occurs, making it not ideal as an entry point for a CLI. See runProgram for a wrapper function that handles exceptions and sets the exit code for you.
Note: when the special GracefulEarlyExitError
exception is thrown from
within a command's handler or builder, Executor
will set
context.state.deepestParseResult
to NullArguments
and
context.state.isGracefullyExiting
to true
. Further, Executor
will
not re-throw the exception in this special case, returning
NullArguments
instead.
executionContext:
CustomContext
A reference to the global context singleton passed to all other
configuration hooks, command builders, and command handlers. This object
recursively contains some of the same entries as its enclosing
PreExecutionContext
.
rootPrograms:
Programs
An object containing the effector, helper, and router Program instances belonging to the root command.
• CustomContext extends ExecutionContext
= ExecutionContext