Skip to content

Commit

Permalink
docs(cli): add missing documentation (#4467)
Browse files Browse the repository at this point in the history
  • Loading branch information
iuioiua authored Mar 11, 2024
1 parent de23a76 commit b3d1239
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
8 changes: 8 additions & 0 deletions cli/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand Down
1 change: 1 addition & 0 deletions cli/prompt_secret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 15 additions & 2 deletions cli/spinner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit b3d1239

Please sign in to comment.