Skip to content

Latest commit

 

History

History
216 lines (129 loc) · 8.63 KB

runProgram.md

File metadata and controls

216 lines (129 loc) · 8.63 KB

@black-flag/coreDocs


@black-flag/core / index / runProgram

Function: runProgram()

runProgram(args)

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.

Type Parameters

CustomCliArguments extends Record<string, unknown> = Record<string, unknown>

Parameters

• ...args: [string]

Returns

Promise<NullArguments | Arguments<CustomCliArguments> | undefined>

NullArguments if GracefulEarlyExitError is thrown, undefined if any other error occurs, or Arguments otherwise.

Defined in

src/util.ts:173

runProgram(args)

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.

Type Parameters

CustomCliArguments extends Record<string, unknown> = Record<string, unknown>

Parameters

• ...args: [string, Promisable<ConfigurationHooks>]

Returns

Promise<NullArguments | Arguments<CustomCliArguments> | undefined>

NullArguments if GracefulEarlyExitError is thrown, undefined if any other error occurs, or Arguments otherwise.

Defined in

src/util.ts:194

runProgram(args)

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.

Type Parameters

CustomCliArguments extends Record<string, unknown> = Record<string, unknown>

Parameters

• ...args: [string, Promisable<PreExecutionContext>]

Returns

Promise<NullArguments | Arguments<CustomCliArguments> | undefined>

NullArguments if GracefulEarlyExitError is thrown, undefined if any other error occurs, or Arguments otherwise.

Defined in

src/util.ts:215

runProgram(args)

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.

Type Parameters

CustomCliArguments extends Record<string, unknown> = Record<string, unknown>

Parameters

• ...args: [string, string | string[]]

Returns

Promise<NullArguments | Arguments<CustomCliArguments>>

NullArguments if GracefulEarlyExitError is thrown, undefined if any other error occurs, or Arguments otherwise.

Defined in

src/util.ts:239

runProgram(args)

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.

Type Parameters

CustomCliArguments extends Record<string, unknown> = Record<string, unknown>

Parameters

• ...args: [string, string | string[], Promisable<ConfigurationHooks>]

Returns

Promise<NullArguments | Arguments<CustomCliArguments>>

NullArguments if GracefulEarlyExitError is thrown, undefined if any other error occurs, or Arguments otherwise.

Defined in

src/util.ts:261

runProgram(args)

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.

Type Parameters

CustomCliArguments extends Record<string, unknown> = Record<string, unknown>

Parameters

• ...args: [string, string | string[], Promisable<PreExecutionContext>]

Returns

Promise<NullArguments | Arguments<CustomCliArguments>>

NullArguments if GracefulEarlyExitError is thrown, undefined if any other error occurs, or Arguments otherwise.

Defined in

src/util.ts:287