Skip to content

Type Alias: CommanderCLIEntrypointOptions ​

CommanderCLIEntrypointOptions = object

The options of commanderCLIEntrypoint.

Properties ​

argv? ​

optional argv?: string[]

The command-line arguments to parse, without the node executable and the script.

Default ​

ts
process.argv.slice(2)

bin? ​

optional bin?: string

The program name shown in the help.

Default ​

ts
the name of the script run, without its extension

configure? ​

optional configure?: (program) => void | Promise<void>

Customize the commander program (hooks, global options, additional commands) after the action commands are added and before the arguments are parsed.

Parameters ​

program ​

Command

Returns ​

void | Promise<void>


description? ​

optional description?: string

The program description shown in the help.


exit? ​

optional exit?: "application" | "process" | "none" | ((code) => void | Promise<void>)

What happens once the command ended, with its exit code (0 on success, 1 on failure, the parser's code for a usage error): 'application' exits the application with the code, 'process' only sets process.exitCode, 'none' does nothing, or a function receiving the code.

Default ​

ts
'application'

format? ​

optional format?: (result) => string | Uint8Array | undefined

Turn an action's result into the text or bytes written to stdout; undefined writes nothing.

Parameters ​

result ​

unknown

Returns ​

string | Uint8Array | undefined

Default ​

a string as is (with a final newline), bytes as is, null and undefined as nothing, any other value as indented JSON (the bigints as strings)


groups? ​

optional groups?: Record<string, string>

The descriptions of the command groups, by group name: the first words of the nested commands ('package' for the command 'package exe <file>'), whose help (tool package --help) lists their commands.


interactive? ​

optional interactive?: boolean | "auto"

Prompt for the missing required options (it needs the optional package @inquirer/prompts): 'auto' when both stdin and stdout are terminals, true always, false never. While prompting is on, the required options are not enforced by the parser; without @inquirer/prompts installed, prompting is off (the parser requires them).

Default ​

ts
'auto'

middlewares? ​

optional middlewares?: MiddlewareDefinition[]

The middlewares of this adapter's actions, run after the entrypoint's global middlewares.


name? ​

optional name?: string

The adapter name, to tell apart several CLI adapters of one entrypoint.


noCommand? ​

optional noCommand?: "help" | "ignore"

What happens when no argument is given: 'help' writes the help and ends with the code 1, 'ignore' runs no command and leaves the application running (an application also serving other channels).

Default ​

ts
'help'

stderr? ​

optional stderr?: NodeJS.WritableStream

The output stream of the errors.

Default ​

ts
process.stderr

stdin? ​

optional stdin?: NodeJS.ReadableStream

The input stream of the prompts.

Default ​

ts
process.stdin

stdout? ​

optional stdout?: NodeJS.WritableStream

The output stream of the results, the help and the prompts.

Default ​

ts
process.stdout

translate? ​

optional translate?: (module) => CLITranslate | Promise<CLITranslate>

Translate the texts of the help and of the prompts (the program, command, argument and option descriptions, the help titles) into the user's language: given the entrypoint's module when the arguments are parsed, it returns the translating function (commanderTranslator of lakutata/com/i18n returns the one of an i18n component). The command and option names are never translated.

Parameters ​

module ​

Module

Returns ​

CLITranslate | Promise<CLITranslate>

Default ​

ts
the English texts

version? ​

optional version?: string

The program version; adds the -V, --version option.

Released under the MIT License.