Module

x/yargs/build/lib/yargs-factory.d.ts>YargsInstance

yargs the modern, pirate-themed successor to optimist.
Go to Latest
class YargsInstance
import { YargsInstance } from "https://dotland.deno.dev/x/yargs@v17.7.1-deno/build/lib/yargs-factory.d.ts";

Constructors

new
YargsInstance(
processArgs: string | string[] | undefined,
cwd: string,
parentRequire: RequireType | undefined,
)

Properties

$0: string
optional
argv: Arguments
customScriptName: boolean
parsed: DetailedArguments | false

Methods

addHelpOpt(opt?: string | false, msg?: string): YargsInstance
addShowHiddenOpt(opt?: string | false, msg?: string): YargsInstance
alias(key: string | string[] | Dictionary<string | string[]>, value?: string | string[]): YargsInstance
array(keys: string | string[]): YargsInstance
boolean(keys: string | string[]): YargsInstance
check(f: (argv: Arguments, options: Options) => any, global?: boolean): YargsInstance
choices(key: string | string[] | Dictionary<string | string[]>, value?: string | string[]): YargsInstance
coerce(keys: string | string[] | Dictionary<CoerceCallback>, value?: CoerceCallback): YargsInstance
command(
description?: CommandHandler["description"],
middlewares?: Middleware[],
deprecated?: boolean,
): YargsInstance
commands(
description?: CommandHandler["description"],
middlewares?: Middleware[],
deprecated?: boolean,
): YargsInstance
completion(
cmd?: string,
desc?: string | false | CompletionFunction,
): YargsInstance
config(
key?: string | string[] | Dictionary,
msg?: string | ConfigCallback,
parseFn?: ConfigCallback,
): YargsInstance
conflicts(key1: string | Dictionary<string | string[]>, key2?: string | string[]): YargsInstance
count(keys: string | string[]): YargsInstance
default(
key: string | string[] | Dictionary<any>,
value?: any,
defaultDescription?: string,
): YargsInstance
defaults(
key: string | string[] | Dictionary<any>,
value?: any,
defaultDescription?: string,
): YargsInstance
demand(
keys:
| string
| string[]
| Dictionary<string | undefined>
| number
,
max?:
| number
| string[]
| string
| true
,
msg?: string | true,
): YargsInstance
demandCommand(
min?: number,
max?: number | string,
minMsg?: string | null,
maxMsg?: string | null,
): YargsInstance
demandOption(keys: string | string[] | Dictionary<string | undefined>, msg?: string): YargsInstance
deprecateOption(option: string, message: string | boolean): YargsInstance
describe(keys: string | string[] | Dictionary<string>, description?: string): YargsInstance
detectLocale(detect: boolean): YargsInstance
env(prefix?: string | false): YargsInstance
epilog(msg: string): YargsInstance
epilogue(msg: string): YargsInstance
example(cmd: string | [string, string][], description?: string): YargsInstance
exit(code: number, err?: YError | string): void
exitProcess(enabled?: boolean): YargsInstance
getAliases(): Dictionary<string[]>
getCompletion(args: string[], done?: (err: Error | null, completions: string[] | undefined) => void): Promise<string[] | void>
getDemandedCommands(): Dictionary<{ min: number; max: number; minMsg?: string | null | undefined; maxMsg?: string | null | undefined; }>
getDemandedOptions(): Dictionary<string | undefined>
getDeprecatedOptions(): Dictionary<string | boolean | undefined>
getDetectLocale(): boolean
getExitProcess(): boolean
getGroups(): Dictionary<string[]>
getHelp(): Promise<string>
getStrict(): boolean
getStrictOptions(): boolean
global(globals: string | string[], global?: boolean): YargsInstance
group(opts: string | string[], groupName: string): YargsInstance
help(opt?: string, msg?: string): YargsInstance
hide(key: string): YargsInstance
locale(locale?: string): YargsInstance | string
middleware(
applyBeforeValidation?: boolean,
global?: boolean,
): YargsInstance
nargs(key: string | string[] | Dictionary<number>, value?: number): YargsInstance
normalize(keys: string | string[]): YargsInstance
number(keys: string | string[]): YargsInstance
parse(
args?: string | string[],
shortCircuit?: object | ParseCallback | boolean,
_parseFn?: ParseCallback,
): Arguments | Promise<Arguments>
parseAsync(
args?: string | string[],
shortCircuit?: object | ParseCallback | boolean,
_parseFn?: ParseCallback,
): Promise<Arguments>
parseSync(
args?: string | string[],
shortCircuit?: object | ParseCallback | boolean,
_parseFn?: ParseCallback,
): Arguments
pkgConf(key: string, rootPath?: string): YargsInstance
positional(key: string, opts: PositionalDefinition): YargsInstance
recommendCommands(recommend?: boolean): YargsInstance
require(
keys:
| string
| string[]
| Dictionary<string | undefined>
| number
,
max?:
| number
| string[]
| string
| true
,
msg?: string | true,
): YargsInstance
required(
keys:
| string
| string[]
| Dictionary<string | undefined>
| number
,
max?:
| number
| string[]
| string
| true
,
msg?: string | true,
): YargsInstance
requiresArg(keys: string | string[] | Dictionary): YargsInstance
scriptName(scriptName: string): YargsInstance
showCompletionScript($0?: string, cmd?: string): YargsInstance
showHelp(level: "error" | "log" | ((message: string) => void)): YargsInstance
showHelpOnFail(enabled?: string | boolean, message?: string): YargsInstance
showHidden(opt?: string | false, msg?: string): YargsInstance
showVersion(level: "error" | "log" | ((message: string) => void)): YargsInstance
skipValidation(keys: string | string[]): YargsInstance
strict(enabled?: boolean): YargsInstance
strictCommands(enabled?: boolean): YargsInstance
strictOptions(enabled?: boolean): YargsInstance
string(keys: string | string[]): YargsInstance
terminalWidth(): number | null
usage(
msg: string | null,
description?: CommandHandler["description"],
): YargsInstance
version(
opt?: string | false,
msg?: string,
ver?: string,
): YargsInstance
wrap(cols: number | nil): YargsInstance
[kCreateLogger](): LoggerInstance
[kDeleteFromParserHintObject](optionKey: string): void
[kEmitWarning](
warning: string,
type: string | undefined,
deduplicationId: string,
): void
[kFreeze](): void
[kGetHasOutput](): boolean
[kGetLoggerInstance](): LoggerInstance
[kGuessVersion](): string
[kPkgUp](rootPath?: string): { [key: string]: string | { [key: string]: string; }; }
[kPopulateParserHintArray]<T extends KeyOf<Options, string[]>>(type: T, keys: string | string[]): void
[kPopulateParserHintArrayDictionary]<T extends DictionaryKeyof<Options, any[]>, K extends keyof Options[T] & string = keyof Options[T] & string, V extends ValueOf<ValueOf<Options[T]>> | ValueOf<ValueOf<Options[T]>>[] = ValueOf<ValueOf<Options[T]>> | ValueOf<ValueOf<Options[T]>>[]>(
builder: (
key: K,
value: V,
...otherArgs: any[],
) => YargsInstance
,
type: T,
key: K | K[] | [key in K]: V,
value?: V,
): void
[kPopulateParserHintDictionary]<T extends keyof Options, K extends keyof Options[T], V>(
builder: (
key: K,
value: V,
...otherArgs: any[],
) => YargsInstance
,
type: T,
key: K | K[] | [key in K]: V,
value: V | undefined,
singleKeyHandler: (
type: T,
key: K,
value?: V,
) => void
,
): void
[kPopulateParserHintSingleValueDictionary]<T extends Exclude<DictionaryKeyof<Options>, DictionaryKeyof<Options, any[]>> | "default", K extends keyof Options[T] & string = keyof Options[T] & string, V extends ValueOf<Options[T]> = ValueOf<Options[T]>>(
builder: (
key: K,
value: V,
...otherArgs: any[],
) => YargsInstance
,
type: T,
key: K | K[] | [key in K]: V,
value?: V,
): void
[kPostProcess]<T extends Arguments | Promise<Arguments>>(
argv: Arguments | Promise<Arguments>,
populateDoubleDash: boolean,
calledFromCommand: boolean,
runGlobalMiddleware: boolean,
): any
[kRebase](base: string, dir: string): string
[kReset](aliases?: Aliases): YargsInstance
[kRunValidation](
aliases: Dictionary<string[]>,
positionalMap: Dictionary<string[]>,
parseErrors: Error | null,
isDefaultCommand?: boolean,
): (argv: Arguments) => void
[kRunYargsParserAndExecuteCommands](
args: string | string[] | null,
shortCircuit?: boolean | null,
calledFromCommand?: boolean,
commandIndex?: number,
helpOnly?: boolean,
): Arguments | Promise<Arguments>
[kSanitizeKey](key: any): any
[kSetKey](key: string | string[] | Dictionary<string | boolean>, set?: boolean | string): this
[kTrackManuallySetKeys](keys: string | string[]): void
[kUnfreeze](): void
[kValidateAsync](validation: (argv: Arguments) => void, argv: Arguments | Promise<Arguments>): Arguments | Promise<Arguments>