From ec5b3345be4d56c9cc11802894786ec50f11aada Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Mon, 11 Mar 2024 17:36:44 +1100 Subject: [PATCH 1/2] docs(cli): add missing documentation --- cli/mod.ts | 8 ++++++++ cli/prompt_secret.ts | 1 + cli/spinner.ts | 17 +++++++++++++++-- example.ts | 4 ++++ 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 example.ts 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; } diff --git a/example.ts b/example.ts new file mode 100644 index 000000000000..8f33125b76bc --- /dev/null +++ b/example.ts @@ -0,0 +1,4 @@ +import { parseArgs } from "https://deno.land/std@$STD_VERSION/cli/parse_args.ts"; + +const parsedArgs = parseArgs(Deno.args); +console.log(parsedArgs); From fa75281699f0802c485fb92cb481f6a60efa2cc5 Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Mon, 11 Mar 2024 17:56:42 +1100 Subject: [PATCH 2/2] fix --- example.ts | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 example.ts diff --git a/example.ts b/example.ts deleted file mode 100644 index 8f33125b76bc..000000000000 --- a/example.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { parseArgs } from "https://deno.land/std@$STD_VERSION/cli/parse_args.ts"; - -const parsedArgs = parseArgs(Deno.args); -console.log(parsedArgs);