ParseOptions
import { ParseOptions } from "jsr:@ende/cli";interface
interface ParseOptions<TBooleans extends BooleanType = BooleanType, TStrings extends StringType = StringType, TCollectable extends Collectable = Collectable, TNegatable extends Negatable = Negatable, TDefault extends Record<string, unknown> | undefined = Record<string, unknown> | undefined, TAliases extends Aliases | undefined = Aliases | undefined, TDoubleDash extends boolean | undefined = boolean | undefined>Options for parseArgs.
Properties
--
--?: TDoubleDashWhen true, populate the result _ with everything before the -- and
the result ['--'] with everything after the --.
Default: false
Example: Double dash option is false
// $ ende run example.ts -- a arg1
import { parseArgs } from "@ende/cli/parse-args";
const args = parseArgs(Ende.args, { "--": false }); // args equals { _: [ "a", "arg1" ] }
Example: Double dash option is true
// $ ende run example.ts -- a arg1
import { parseArgs } from "@ende/cli/parse-args";
const args = parseArgs(Ende.args, { "--": true }); // args equals { _: [], --: [ "a", "arg1" ] }
alias
alias?: TAliasesAn object mapping string names to strings or arrays of string argument names to use as aliases.
Default: {
boolean
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.
Default: false
default
default?: TDefault & Defaults<TBooleans, TStrings>An object mapping string argument names to default values.
Default: {
stopEarly
stopEarly?: booleanWhen true, populate the result _ with everything after the first
non-option.
Default: false
string
string?: TStrings | ReadonlyArray<Extract<TStrings, string>>A string or array of strings argument names to always treat as strings.
Default: []
collect
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.
Default: []
negatable
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.
Default: []
unknown
unknown?: (arg: string, key?: string, value?: unknown) => unknownA 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.
Default: unknown