@black-flag/core • Docs
@black-flag/core / index / runProgram
runProgram<
CustomCliArguments
>(...args
):Promise
<NullArguments
|Arguments
<CustomCliArguments
> |undefined
>
Invokes the dynamically imported
configureProgram(commandModulePath).execute()
function.
This function is suitable for a CLI entry point since it will never throw
or reject no matter what. Instead, when an error is caught,
process.exitCode
is set to the appropriate value and either NullArguments
(only if GracefulEarlyExitError
was thrown) or undefined
is returned.
Note: It is always safe to invoke this form of runProgram
as many times as
desired.
• CustomCliArguments extends Record
<string
, unknown
> = Record
<string
, unknown
>
• ...args: [string
]
Promise
<NullArguments
| Arguments
<CustomCliArguments
> | undefined
>
NullArguments
if GracefulEarlyExitError
is thrown, undefined
if any other error occurs, or Arguments
otherwise.
runProgram<
CustomCliArguments
>(...args
):Promise
<NullArguments
|Arguments
<CustomCliArguments
> |undefined
>
Invokes the dynamically imported configureProgram(commandModulePath, configurationHooks).execute()
function.
This function is suitable for a CLI entry point since it will never throw
or reject no matter what. Instead, when an error is caught,
process.exitCode
is set to the appropriate value and either NullArguments
(only if GracefulEarlyExitError
was thrown) or undefined
is returned.
Note: It is always safe to invoke this form of runProgram
as many times as
desired.
• CustomCliArguments extends Record
<string
, unknown
> = Record
<string
, unknown
>
• ...args: [string
, Promisable
<ConfigurationHooks
>]
Promise
<NullArguments
| Arguments
<CustomCliArguments
> | undefined
>
NullArguments
if GracefulEarlyExitError
is thrown, undefined
if any other error occurs, or Arguments
otherwise.
runProgram<
CustomCliArguments
>(...args
):Promise
<NullArguments
|Arguments
<CustomCliArguments
> |undefined
>
Invokes the preExecutionContext.execute()
function.
WARNING: reusing the same preExecutionContext
with multiple invocations
of runProgram
will cause successive invocations to fail. This is because
yargs does not support calling yargs::parseAsync
more than once. If this is
unacceptable, do not pass runProgram
a preExecutionContext
property.
This function is suitable for a CLI entry point since it will never throw
or reject no matter what. Instead, when an error is caught,
process.exitCode
is set to the appropriate value and either NullArguments
(only if GracefulEarlyExitError
was thrown) or undefined
is returned.
• CustomCliArguments extends Record
<string
, unknown
> = Record
<string
, unknown
>
• ...args: [string
, Promisable
<PreExecutionContext
>]
Promise
<NullArguments
| Arguments
<CustomCliArguments
> | undefined
>
NullArguments
if GracefulEarlyExitError
is thrown, undefined
if any other error occurs, or Arguments
otherwise.
runProgram<
CustomCliArguments
>(...args
):Promise
<NullArguments
|Arguments
<CustomCliArguments
>>
Invokes the dynamically imported
configureProgram(commandModulePath).execute(argv)
function. If argv
is a
string, argv = argv.split(' ')
is applied first.
This function is suitable for a CLI entry point since it will never throw
or reject no matter what. Instead, when an error is caught,
process.exitCode
is set to the appropriate value and either NullArguments
(only if GracefulEarlyExitError
was thrown) or undefined
is returned.
Note: It is always safe to invoke this form of runProgram
as many times as
desired.
• CustomCliArguments extends Record
<string
, unknown
> = Record
<string
, unknown
>
• ...args: [string
, string
| string
[]]
Promise
<NullArguments
| Arguments
<CustomCliArguments
>>
NullArguments
if GracefulEarlyExitError
is thrown, undefined
if any other error occurs, or Arguments
otherwise.
runProgram<
CustomCliArguments
>(...args
):Promise
<NullArguments
|Arguments
<CustomCliArguments
>>
Invokes the dynamically imported configureProgram(commandModulePath, configurationHooks).execute(argv)
function. If argv
is a string, argv = argv.split(' ')
is applied first.
This function is suitable for a CLI entry point since it will never throw
or reject no matter what. Instead, when an error is caught,
process.exitCode
is set to the appropriate value and either NullArguments
(only if GracefulEarlyExitError
was thrown) or undefined
is returned.
Note: It is always safe to invoke this form of runProgram
as many times as
desired.
• CustomCliArguments extends Record
<string
, unknown
> = Record
<string
, unknown
>
• ...args: [string
, string
| string
[], Promisable
<ConfigurationHooks
>]
Promise
<NullArguments
| Arguments
<CustomCliArguments
>>
NullArguments
if GracefulEarlyExitError
is thrown, undefined
if any other error occurs, or Arguments
otherwise.
runProgram<
CustomCliArguments
>(...args
):Promise
<NullArguments
|Arguments
<CustomCliArguments
>>
Invokes the preExecutionContext.execute(argv)
function. If argv
is a
string, argv = argv.split(' ')
is applied first.
WARNING: reusing the same preExecutionContext
with multiple invocations
of runProgram
will cause successive invocations to fail. This is because
yargs does not support calling yargs::parseAsync
more than once. If this is
unacceptable, do not pass runProgram
a preExecutionContext
property.
This function is suitable for a CLI entry point since it will never throw
or reject no matter what. Instead, when an error is caught,
process.exitCode
is set to the appropriate value and either NullArguments
(only if GracefulEarlyExitError
was thrown) or undefined
is returned.
• CustomCliArguments extends Record
<string
, unknown
> = Record
<string
, unknown
>
• ...args: [string
, string
| string
[], Promisable
<PreExecutionContext
>]
Promise
<NullArguments
| Arguments
<CustomCliArguments
>>
NullArguments
if GracefulEarlyExitError
is thrown, undefined
if any other error occurs, or Arguments
otherwise.