Skip to content

Latest commit

 

History

History
106 lines (57 loc) · 2.91 KB

Program.md

File metadata and controls

106 lines (57 loc) · 2.91 KB

@black-flag/coreDocs


@black-flag/core / util / Program

Type Alias: Program<CustomCliArguments, CustomExecutionContext>

Program<CustomCliArguments, CustomExecutionContext>: Omit<_Program<FrameworkArguments<CustomExecutionContext> & CustomCliArguments>, "command" | "onFinishCommand" | "showHelpOnFail" | "version" | "help" | "exitProcess" | "commandDir" | "parse" | "parsed" | "parseSync" | "argv"> & object

Represents a pre-configured yargs instance ready for argument parsing and execution.

Program is essentially a drop-in replacement for the Argv type exported by yargs but with several differences and should be preferred.

Type declaration

command()

command: (command, description, builder, handler, middlewares, deprecated) => Program<CustomCliArguments, CustomExecutionContext>

Internal

Parameters

command: string[]

description: string | false

builder: (yargs, helpOrVersionSet) => Argv<object> | Record<string, never>

handler

middlewares: []

deprecated: string | boolean

Returns

Program<CustomCliArguments, CustomExecutionContext>

See

_Program.command

command_deferred

command_deferred: Program<CustomCliArguments, CustomExecutionContext>["command"]

Internal

Identical to yargs::command except its execution is enqueued and deferred until Program.command_finalize_deferred is called.

See

_Program.command

command_finalize_deferred()

command_finalize_deferred: () => void

Internal

Returns

void

See

Program.command_deferred

showHelpOnFail()

showHelpOnFail: (enabled) => Program<CustomCliArguments, CustomExecutionContext>

Like yargs::showHelpOnFail except (1) it also determines if help text is shown when executing an unimplemented parent command and (2) it has no second message parameter. If you want to output some specific error message, use a configuration hook or yargs::epilogue.

Invoking this method will affect all programs in your command hierarchy, not just the program on which it was invoked.

Parameters

enabled: boolean

Returns

Program<CustomCliArguments, CustomExecutionContext>

See

_Program.showHelpOnFail

Type Parameters

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

CustomExecutionContext extends ExecutionContext = ExecutionContext

Defined in

types/program.ts:44