Skip to main content
Home
This release is 16 versions behind 1.0.25 — the latest version of @std/cli. Jump to latest

@std/cli@1.0.9
Built and signed on GitHub Actions

Works with
This package works with DenoIt is unknown whether this package works with Bun
This package works with Deno
It is unknown whether this package works with Bun
JSR Score94%
Downloads10,077/wk
Publisheda year ago (1.0.9)

Tools for creating interactive command line tools

interface ParseOptions

Options for parseArgs.

Type Parameters

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

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>> = false

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 = false

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.

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
= 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.

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/cli

Import symbol

import { type ParseOptions } from "@std/cli";
or

Import directly with a jsr specifier

import { type ParseOptions } from "jsr:@std/cli";

Add Package

bunx jsr add @std/cli

Import symbol

import { type ParseOptions } from "@std/cli";