Skip to content

Commit 96c1534

Browse files
authored
docs(cli): fix options arguments display (denoland#5486)
* docs(cli): fix options presentation * work
1 parent ff60cef commit 96c1534

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

cli/parse_args.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ const FLAG_REGEXP =
449449
* or `options.boolean` is set for that argument name.
450450
*
451451
* @param args An array of command line arguments.
452+
* @param options Options for the parse function.
452453
*
453454
* @typeParam TArgs Type of result.
454455
* @typeParam TDoubleDash Used by `TArgs` for the result.
@@ -496,7 +497,17 @@ export function parseArgs<
496497
TAliasNames extends string = string,
497498
>(
498499
args: string[],
499-
{
500+
options?: ParseOptions<
501+
TBooleans,
502+
TStrings,
503+
TCollectable,
504+
TNegatable,
505+
TDefaults,
506+
TAliases,
507+
TDoubleDash
508+
>,
509+
): Args<TArgs, TDoubleDash> {
510+
const {
500511
"--": doubleDash = false,
501512
alias = {} as NonNullable<TAliases>,
502513
boolean = false,
@@ -506,16 +517,7 @@ export function parseArgs<
506517
collect = [],
507518
negatable = [],
508519
unknown: unknownFn = (i: string): unknown => i,
509-
}: ParseOptions<
510-
TBooleans,
511-
TStrings,
512-
TCollectable,
513-
TNegatable,
514-
TDefaults,
515-
TAliases,
516-
TDoubleDash
517-
> = {},
518-
): Args<TArgs, TDoubleDash> {
520+
} = options ?? {};
519521
const aliasMap: Map<string, Set<string>> = new Map();
520522
const booleanSet = new Set<string>();
521523
const stringSet = new Set<string>();

cli/prompt_secret.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export type PromptSecretOptions = {
2929
* Use an empty `mask` if you don't want to show any character.
3030
*
3131
* @param message The prompt message to show to the user.
32+
* @param options The options for the prompt.
3233
* @returns The string that was entered or `null` if stdin is not a TTY.
3334
*
3435
* @example Usage
@@ -43,8 +44,10 @@ export type PromptSecretOptions = {
4344
*/
4445
export function promptSecret(
4546
message = "Secret",
46-
{ mask = "*", clear }: PromptSecretOptions = {},
47+
options?: PromptSecretOptions,
4748
): string | null {
49+
const { mask = "*", clear } = options ?? {};
50+
4851
if (!input.isTerminal()) {
4952
return null;
5053
}

cli/spinner.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ export class Spinner {
139139
/**
140140
* Creates a new spinner.
141141
*
142+
* @param options Options for the spinner.
143+
*
142144
* @example Usage
143145
* ```ts no-assert
144146
* import { Spinner } from "@std/cli/spinner";
@@ -147,12 +149,13 @@ export class Spinner {
147149
* spinner.stop();
148150
* ```
149151
*/
150-
constructor({
151-
spinner = DEFAULT_SPINNER,
152-
message = "",
153-
interval = DEFAULT_INTERVAL,
154-
color,
155-
}: SpinnerOptions = {}) {
152+
constructor(options?: SpinnerOptions) {
153+
const {
154+
spinner = DEFAULT_SPINNER,
155+
message = "",
156+
interval = DEFAULT_INTERVAL,
157+
color,
158+
} = options ?? {};
156159
this.#spinner = spinner;
157160
this.message = message;
158161
this.#interval = interval;

0 commit comments

Comments
 (0)