close
Skip to main content
This release is versions behind 1.0.30 — the latest version of @std/cli.

@std/cli@1.0.29
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%
License
MIT
Downloads22,477/wk
Publisheda month ago (1.0.29)

Tools for creating interactive command line tools

Classes

c
Spinner(unnamed 0?: SpinnerOptions)

A spinner that can be used to indicate that something is loading.

  • color(value: Color | undefined): void
    No documentation available
  • message: string
    No documentation available
  • start(): void

    Starts the spinner.

  • stop(): void

    Stops the spinner.

Functions

f
parseArgs<
TArgs extends Values<
TBooleans,
TStrings,
TCollectable,
TNegatable,
TDefaults,
TAliases
>
,
TDoubleDash extends boolean | undefined = undefined,
TBooleans extends BooleanType = undefined,
TStrings extends StringType = undefined,
TCollectable extends Collectable = undefined,
TNegatable extends Negatable = undefined,
TDefaults extends Record<string, unknown> | undefined = undefined,
TAliases extends Aliases<TAliasArgNames, TAliasNames> | undefined = undefined,
TAliasArgNames extends string = string,
TAliasNames extends string = string
>
(
args: readonly string[],
options?: ParseOptions<
TBooleans,
TStrings,
TCollectable,
TNegatable,
TDefaults,
TAliases,
TDoubleDash
>
): Args<TArgs, TDoubleDash>

Take a set of command line arguments, optionally with a set of options, and return an object representing the flags found in the passed arguments.

f
promptSecret(
message?: string,
options?: PromptSecretOptions
): string | null

Shows the given message and waits for the user's input. Returns the user's input as string. This is similar to prompt() but it print user's input as * to prevent password from being shown. Use an empty mask if you don't want to show any character.

f
unicodeWidth(str: string): number

Calculate the physical width of a string in a TTY-like environment. This is useful for cases such as calculating where a line-wrap will occur and underlining strings.

Interfaces

I

Options for parseArgs.

  • --: TDoubleDash

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

  • alias: TAliases

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

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

  • 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: TDefault & Defaults<TBooleans, TStrings>

    An object mapping string argument names to default values.

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

  • stopEarly: boolean

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

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

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

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

I

Options for Spinner.

  • color: Color

    The color of the spinner. Defaults to the default terminal color. This can be changed while the spinner is active.

  • interval: number

    The time between each frame of the spinner in milliseconds.

  • message: string

    The message to display next to the spinner. This can be changed while the spinner is active.

  • spinner: string[]

    The sequence of characters to be iterated through for animation.

Type Aliases

T
Ansi = string & { }
No documentation available
T
Args<
TArgs extends Record<string, unknown> = Record<string, any>,
TDoubleDash extends boolean | undefined = undefined
>
= Id<
TArgs
& { _: Array<string | number>; }
& (boolean extends TDoubleDash ? DoubleDash : true extends TDoubleDash ? Required<DoubleDash> : Record<never, never>)
>

The value returned from parseArgs.

T
Color =
"black"
| "red"
| "green"
| "yellow"
| "blue"
| "magenta"
| "cyan"
| "white"
| "gray"
| Ansi
No documentation available
T
PromptSecretOptions = { mask?: string; clear?: boolean; }

Options for promptSecret.