Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/cliffy/command/command.ts>Command#option

Command line framework for deno 🦕 Including Commandline-Interfaces, Prompts, CLI-Table, Arguments Parser and more...
Extremely Popular
Go to Latest
method Command.prototype.option
import { Command } from "https://deno.land/x/cliffy@v1.0.0-rc.2/command/command.ts";

Add a global option.

Type Parameters

TFlags extends string
TGlobalOptions extends TypedOption<TFlags, TCommandOptions, Merge<TParentCommandTypes, Merge<TCommandGlobalTypes, TCommandTypes>>, undefined extends TConflicts ? TRequired : false, TDefault>
TMappedGlobalOptions extends MapValue<TGlobalOptions, TMappedValue, TCollect>
optional
TRequired extends OptionOptions["required"] = undefined
optional
TCollect extends OptionOptions["collect"] = undefined
optional
TConflicts extends OptionOptions["conflicts"] = undefined
optional
TDefault = undefined
optional
TMappedValue = undefined

Parameters

flags: TFlags

Flags string e.g: -h, --help, --manual requiredArg:string [optionalArg:number] [...restArgs:string]

desc: string

Flag description.

opts: Omit<OptionOptions<Partial<TCommandOptions>, TCommandArguments, MergeOptions<TFlags, TCommandGlobals, TGlobalOptions>, TParentCommandGlobals, TCommandTypes, TCommandGlobalTypes, TParentCommandTypes, TParentCommand>, "value"> & { global: true; default?: DefaultValue<TDefault>; required?: TRequired; collect?: TCollect; value?: OptionValueHandler<MapTypes<ValueOf<TGlobalOptions>>, TMappedValue>; } | OptionValueHandler<MapTypes<ValueOf<TGlobalOptions>>, TMappedValue>

Flag options or custom handler for processing flag value.

Returns

Command<TParentCommandGlobals, TParentCommandTypes, TCommandOptions, TCommandArguments, MergeOptions<TFlags, TCommandGlobals, TMappedGlobalOptions>, TCommandTypes, TCommandGlobalTypes, TParentCommand>

Register an option.

Type Parameters

TFlags extends string
TOptions extends TypedOption<TFlags, TCommandOptions, Merge<TParentCommandTypes, Merge<TCommandGlobalTypes, TCommandTypes>>, undefined extends TConflicts ? TRequired : false, TDefaultValue>
TMappedOptions extends MapValue<TOptions, TMappedValue, TCollect>
optional
TRequired extends OptionOptions["required"] = undefined
optional
TCollect extends OptionOptions["collect"] = undefined
optional
TConflicts extends OptionOptions["conflicts"] = undefined
optional
TDefaultValue = undefined
optional
TMappedValue = undefined

Parameters

flags: TFlags

Flags string e.g: -h, --help, --manual requiredArg:string [optionalArg:number] [...restArgs:string]

desc: string

Flag description.

optional
opts: Omit<OptionOptions<MergeOptions<TFlags, TCommandOptions, TMappedOptions>, TCommandArguments, TCommandGlobals, TParentCommandGlobals, TCommandTypes, TCommandGlobalTypes, TParentCommandTypes, TParentCommand>, "value"> & { default?: DefaultValue<TDefaultValue>; required?: TRequired; collect?: TCollect; conflicts?: TConflicts; value?: OptionValueHandler<MapTypes<ValueOf<TOptions>>, TMappedValue>; } | OptionValueHandler<MapTypes<ValueOf<TOptions>>, TMappedValue>

Flag options or custom handler for processing flag value.

Returns

Command<TParentCommandGlobals, TParentCommandTypes, MergeOptions<TFlags, TCommandOptions, TMappedOptions>, TCommandArguments, TCommandGlobals, TCommandTypes, TCommandGlobalTypes, TParentCommand>