481
}
482
completion(
484
>
desc?: string | false | CompletionFunction,
485
>
fn?: CompletionFunction
486
>
): YargsInstance {
487
>
argsert(
488
>
'[string] [string|boolean|function] [function]',
489
>
[cmd, desc, fn],
490
>
arguments.length
491
>
);
492
>
493
>
// a function to execute when generating
494
>
// completions can be provided as the second
495
>
// or third argument to completion.
496
>
if (typeof desc === 'function') {
497
fn = desc;
498
desc = undefined;
499
}
501
>
// register the completion command.
502
>
this.#completionCommand = cmd || this.#completionCommand || 'completion';
503
>
if (!desc && desc !== false) {
504
desc = 'generate completion script';
505
}
507
>
508
>
// a function can be provided
509
>
if (fn) this.#completion!.registerFunction(fn);
510
>
511
>
return this;
512
>
}
513
command(
514
cmd: string | CommandHandlerDefinition | DefinitionOrCommandName[],