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

x/frugal/dep/std/flags.ts>ParseOptions

A frugal web framework
Go to Latest
interface ParseOptions
import { type ParseOptions } from "https://deno.land/x/frugal@0.3.0/dep/std/flags.ts";

The options for the parse call.

Type Parameters

optional
B extends BooleanType = BooleanType
optional
S extends StringType = StringType
optional
C extends Collectable = Collectable
optional
N extends Negatable = Negatable
optional
D extends Record<string, unknown> | undefined = Record<string, unknown> | undefined
optional
A extends Aliases<string, string> | undefined = Aliases<string, string> | undefined
optional
DD extends boolean | undefined = boolean | undefined

Properties

optional
--: DD

When true, populate the result _ with everything before the -- and the result ['--'] with everything after the --. Here's an example:

// $ deno run example.ts -- a arg1
import { parse } from "./mod.ts";
console.dir(parse(Deno.args, { "--": false }));
// output: { _: [ "a", "arg1" ] }
console.dir(parse(Deno.args, { "--": true }));
// output: { _: [], --: [ "a", "arg1" ] }

Defaults to false.

optional
alias: A

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

optional
boolean: B | ReadonlyArray<Extract<B, 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)

optional
default: D & Defaults<B, S>

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: S | ReadonlyArray<Extract<S, string>>

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

optional
collect: C | ReadonlyArray<Extract<C, 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.

optional
negatable: N | ReadonlyArray<Extract<N, 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.