Skip to main content
Module

std/flags/mod.ts>ParseOptions

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
interface ParseOptions
Deprecated
Deprecated

(will be removed in 1.0.0) Import from https://deno.land/std/cli/parse_args.ts instead.

import { type ParseOptions } from "https://deno.land/std@0.218.2/flags/mod.ts";

The options for the parse call.

Type Parameters

optional
TBooleans extends BooleanType = BooleanType
optional
TStrings extends StringType = StringType
optional
TCollectable extends Collectable = Collectable
optional
TNegatable extends Negatable = Negatable
optional
TDefault extends Record<string, unknown> | undefined = Record<string, unknown> | undefined
optional
TAliases extends Aliases | undefined = Aliases | undefined
optional
TDoubleDash extends boolean | undefined = boolean | undefined

Properties

optional
--: TDoubleDash = false

When true, populate the result _ with everything before the -- and the result ['--'] with everything after the --.

optional
alias: TAliases

An object mapping string names to strings or arrays of string argument names to use as aliases.

optional
boolean: TBooleans | ReadonlyArray<Extract<TBooleans, string>>

A boolean, string or array of strings to always treat as booleans. If true will treat all double hyphenated arguments without equal signs as boolean (e.g. affects --foo, not -f or --foo=bar). All boolean arguments will be set to false by default.

optional
default: TDefault & Defaults<TBooleans, TStrings>

An object mapping string argument names to default values.

optional
stopEarly: boolean

When true, populate the result _ with everything after the first non-option.

optional
string: TStrings | ReadonlyArray<Extract<TStrings, string>>

A string or array of strings argument names to always treat as strings.

optional
collect: TCollectable | ReadonlyArray<Extract<TCollectable, string>>

A string or array of strings argument names to always treat as arrays. Collectable options can be used multiple times. All values will be collected into one array. If a non-collectable option is used multiple times, the last value is used. All Collectable arguments will be set to [] by default.

optional
negatable: TNegatable | ReadonlyArray<Extract<TNegatable, string>>

A string or array of strings argument names which can be negated by prefixing them with --no-, like --no-config.

optional
unknown: (
arg: string,
key?: string,
value?: unknown,
) => unknown

A function which is invoked with a command line parameter not defined in the options configuration object. If the function returns false, the unknown option is not added to parsedArgs.