From b3d12393fedf2eaca575542317728be0d4e2146d Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Mon, 11 Mar 2024 20:30:39 +1100 Subject: [PATCH] docs(cli): add missing documentation (#4467) --- cli/mod.ts | 8 ++++++++ cli/prompt_secret.ts | 1 + cli/spinner.ts | 17 +++++++++++++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/cli/mod.ts b/cli/mod.ts index 0d61478607d9..ea40381bffb1 100644 --- a/cli/mod.ts +++ b/cli/mod.ts @@ -3,6 +3,14 @@ /** * Tools for creating interactive command line tools. * + * ```ts + * // $ deno run example.ts --foo --bar=baz ./quux.txt + * import { parseArgs } from "https://deno.land/std@$STD_VERSION/cli/parse_args.ts"; + * + * const parsedArgs = parseArgs(Deno.args); + * parsedArgs; // { foo: true, bar: "baz", _: ["./quux.txt"] } + * ``` + * * @module */ diff --git a/cli/prompt_secret.ts b/cli/prompt_secret.ts index 55dadbd506e3..27df0c34b622 100644 --- a/cli/prompt_secret.ts +++ b/cli/prompt_secret.ts @@ -15,6 +15,7 @@ const setRawOptions = Deno.build.os === "windows" ? undefined : { cbreak: true }; +/** Options for {@linkcode promptSecret}. */ export type PromptSecretOptions = { /** A character to print instead of the user's input. */ mask?: string; diff --git a/cli/spinner.ts b/cli/spinner.ts index 8f5f53afd320..295c766377ff 100644 --- a/cli/spinner.ts +++ b/cli/spinner.ts @@ -10,10 +10,18 @@ const COLOR_RESET = "\u001b[0m"; const DEFAULT_INTERVAL = 75; const DEFAULT_SPINNER = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]; -// This is a hack to allow us to use the same type for both the color name and an ANSI escape code. -// ref: https://github.com/microsoft/TypeScript/issues/29729#issuecomment-460346421 +/** + * This is a hack to allow us to use the same type for both the color name and + * an ANSI escape code. + * + * @see {@link https://github.com/microsoft/TypeScript/issues/29729#issuecomment-460346421} + * + * @internal + */ // deno-lint-ignore ban-types export type Ansi = string & {}; + +/** Color options for {@linkcode SpinnerOptions.color}. */ export type Color = | "black" | "red" @@ -69,6 +77,7 @@ export interface SpinnerOptions { */ export class Spinner { #spinner: string[]; + /** The message to display next to the spinner. */ message: string; #interval: number; #color?: Color; @@ -99,6 +108,10 @@ export class Spinner { this.color = color; } + /** + * Set the color of the spinner. This defaults to the default terminal color. + * This can be changed while the spinner is active. + */ set color(value: Color | undefined) { this.#color = value ? COLORS[value] : undefined; }