Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(cli): add missing documentation #4467

Merged
merged 2 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading