Skip to main content
Home
This release is 17 versions behind 1.0.26 — 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%
Downloads27,646/wk
Publisheda year ago (1.0.9)

Tools for creating interactive command line tools

function promptSecret
promptSecret(
message?: string,
): 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.

Examples

Usage

import { promptSecret } from "@std/cli/prompt-secret";

const password = promptSecret("Please provide the password:");
if (password !== "some-password") {
  throw new Error("Access denied");
}

Parameters

optional
message: string = Secret

The prompt message to show to the user.

optional
options: PromptSecretOptions

The options for the prompt.

Return Type

string | null

The string that was entered or null if stdin is not a TTY.

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 { promptSecret } from "@std/cli";
or

Import directly with a jsr specifier

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

Add Package

bunx jsr add @std/cli

Import symbol

import { promptSecret } from "@std/cli";