Skip to content

Commit 128ff84

Browse files
committed
Address PR comments: small copy changes, default option for multiselect
1 parent f0ffcd7 commit 128ff84

File tree

4 files changed

+181
-142
lines changed

4 files changed

+181
-142
lines changed

packages/wrangler/src/__tests__/r2.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ describe("r2", () => {
101101
wrangler r2 bucket notification Manage event notification rules for an R2 bucket
102102
wrangler r2 bucket domain Manage custom domains for an R2 bucket
103103
wrangler r2 bucket dev-url Manage public access via the r2.dev URL for an R2 bucket
104-
wrangler r2 bucket lifecycle Manage lifecycle rules for an R2 bucket
104+
wrangler r2 bucket lifecycle Manage lifecycle rules for an R2 bucket
105105
106106
GLOBAL FLAGS
107107
-j, --experimental-json-config Experimental: support wrangler.json [boolean]
@@ -139,7 +139,7 @@ describe("r2", () => {
139139
wrangler r2 bucket notification Manage event notification rules for an R2 bucket
140140
wrangler r2 bucket domain Manage custom domains for an R2 bucket
141141
wrangler r2 bucket dev-url Manage public access via the r2.dev URL for an R2 bucket
142-
wrangler r2 bucket lifecycle Manage lifecycle rules for an R2 bucket
142+
wrangler r2 bucket lifecycle Manage lifecycle rules for an R2 bucket
143143
144144
GLOBAL FLAGS
145145
-j, --experimental-json-config Experimental: support wrangler.json [boolean]
@@ -1003,7 +1003,7 @@ binding = \\"testBucket\\""
10031003
"
10041004
wrangler r2 bucket notification list <bucket>
10051005
1006-
List event notification rules for a bucket
1006+
List event notification rules for an R2 bucket
10071007
10081008
POSITIONALS
10091009
bucket The name of the R2 bucket to get event notification rules for [string] [required]

packages/wrangler/src/dialogs.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,31 @@ export async function select<Values extends string>(
131131
return value;
132132
}
133133

134+
interface MultiSelectOptions<Values> {
135+
choices: SelectOption<Values>[];
136+
defaultOptions?: number[];
137+
}
138+
134139
export async function multiselect<Values extends string>(
135140
text: string,
136-
options: SelectOptions<Values>
141+
options: MultiSelectOptions<Values>
137142
): Promise<Values[]> {
138143
if (isNonInteractiveOrCI()) {
139-
throw new NoDefaultValueProvided();
144+
if (options?.defaultOptions === undefined) {
145+
throw new NoDefaultValueProvided();
146+
}
147+
148+
const defaultTitles = options.defaultOptions.map(
149+
(index) => options.choices[index].title
150+
);
151+
logger.log(`? ${text}`);
152+
153+
logger.log(
154+
`🤖 ${chalk.dim(
155+
"Using default value(s) in non-interactive context:"
156+
)} ${chalk.white.bold(defaultTitles.join(", "))}`
157+
);
158+
return options.defaultOptions.map((index) => options.choices[index].value);
140159
}
141160
const { value } = await prompts({
142161
type: "multiselect",

packages/wrangler/src/r2/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ export function r2(r2Yargs: CommonYargsArgv, subHelp: SubHelp) {
577577
return r2EvNotifyYargs
578578
.command(
579579
["list <bucket>", "get <bucket>"],
580-
"List event notification rules for a bucket",
580+
"List event notification rules for an R2 bucket",
581581
Notification.ListOptions,
582582
Notification.ListHandler
583583
)

0 commit comments

Comments
 (0)