[READ-ONLY] Mirror of https://github.com/bombshell-dev/clack. Effortlessly build beautiful command-line apps bomb.sh/docs/clack/basics/getting-started/
cli command-line command-line-app node prompt prompts
5

Configure Feed

Select the types of activity you want to include in your feed.

[ci] format

authored by

Nate Moore and committed by
bombshell-bot
(Mar 18, 2026, 3:11 AM UTC) ffbdcb0c 28ecc2ae

+60 -28
+58 -19
packages/core/src/prompts/date.ts
··· 15 15 16 16 export type DateFormat = 'YMD' | 'MDY' | 'DMY'; 17 17 18 - const SEGMENTS: Record<string, SegmentConfig> = { Y: { type: 'year', len: 4 }, M: { type: 'month', len: 2 }, D: { type: 'day', len: 2 } } as const; 18 + const SEGMENTS: Record<string, SegmentConfig> = { 19 + Y: { type: 'year', len: 4 }, 20 + M: { type: 'month', len: 2 }, 21 + D: { type: 'day', len: 2 }, 22 + } as const; 19 23 20 24 function segmentsFor(fmt: DateFormat): SegmentConfig[] { 21 25 return [...fmt].map((c) => SEGMENTS[c as keyof typeof SEGMENTS]); ··· 46 50 } 47 51 48 52 function parse(parts: DateParts): { year: number; month: number; day: number } { 49 - return { year: parseSegmentToNum(parts.year), month: parseSegmentToNum(parts.month), day: parseSegmentToNum(parts.day) }; 53 + return { 54 + year: parseSegmentToNum(parts.year), 55 + month: parseSegmentToNum(parts.month), 56 + day: parseSegmentToNum(parts.day), 57 + }; 50 58 } 51 59 52 60 function daysInMonth(year: number, month: number): number { ··· 54 62 } 55 63 56 64 /** Validate and return calendar parts, or undefined if invalid */ 57 - function validParts( 58 - parts: DateParts 59 - ): { year: number; month: number; day: number } | undefined { 65 + function validParts(parts: DateParts): { year: number; month: number; day: number } | undefined { 60 66 const { year, month, day } = parse(parts); 61 67 if (!year || year < 0 || year > 9999) return undefined; 62 68 if (!month || month < 1 || month > 12) return undefined; ··· 79 85 maxDate: Date | undefined 80 86 ): { min: number; max: number } { 81 87 const minP = minDate 82 - ? { year: minDate.getUTCFullYear(), month: minDate.getUTCMonth() + 1, day: minDate.getUTCDate() } 88 + ? { 89 + year: minDate.getUTCFullYear(), 90 + month: minDate.getUTCMonth() + 1, 91 + day: minDate.getUTCDate(), 92 + } 83 93 : null; 84 94 const maxP = maxDate 85 - ? { year: maxDate.getUTCFullYear(), month: maxDate.getUTCMonth() + 1, day: maxDate.getUTCDate() } 95 + ? { 96 + year: maxDate.getUTCFullYear(), 97 + month: maxDate.getUTCMonth() + 1, 98 + day: maxDate.getUTCDate(), 99 + } 86 100 : null; 87 101 88 102 if (type === 'year') { ··· 96 110 } 97 111 return { 98 112 min: minP && ctx.year === minP.year && ctx.month === minP.month ? minP.day : 1, 99 - max: maxP && ctx.year === maxP.year && ctx.month === maxP.month ? maxP.day : daysInMonth(ctx.year, ctx.month), 113 + max: 114 + maxP && ctx.year === maxP.year && ctx.month === maxP.month 115 + ? maxP.day 116 + : daysInMonth(ctx.year, ctx.month), 100 117 }; 101 118 } 102 119 ··· 186 203 const index = Math.max(0, Math.min(this.#cursor.segmentIndex, this.#segments.length - 1)); 187 204 const segment = this.#segments[index]; 188 205 if (!segment) return undefined; 189 - this.#cursor.positionInSegment = Math.max(0, Math.min(this.#cursor.positionInSegment, segment.len - 1)); 206 + this.#cursor.positionInSegment = Math.max( 207 + 0, 208 + Math.min(this.#cursor.positionInSegment, segment.len - 1) 209 + ); 190 210 return { segment, index }; 191 211 } 192 212 ··· 195 215 this.#pendingTensDigit = null; 196 216 const ctx = this.#seg(); 197 217 if (!ctx) return; 198 - this.#cursor.segmentIndex = Math.max(0, Math.min(this.#segments.length - 1, ctx.index + direction)); 218 + this.#cursor.segmentIndex = Math.max( 219 + 0, 220 + Math.min(this.#segments.length - 1, ctx.index + direction) 221 + ); 199 222 this.#cursor.positionInSegment = 0; 200 223 this.#segmentSelected = true; 201 224 } ··· 207 230 const raw = this.#segmentValues[segment.type]; 208 231 const isBlank = !raw || raw.replace(/_/g, '') === ''; 209 232 const num = Number.parseInt((raw || '0').replace(/_/g, '0'), 10) || 0; 210 - const bounds = segmentBounds(segment.type, parse(this.#segmentValues), this.#minDate, this.#maxDate); 233 + const bounds = segmentBounds( 234 + segment.type, 235 + parse(this.#segmentValues), 236 + this.#minDate, 237 + this.#maxDate 238 + ); 211 239 212 240 let next: number; 213 241 if (isBlank) { ··· 216 244 next = Math.max(Math.min(bounds.max, num + direction), bounds.min); 217 245 } 218 246 219 - this.#segmentValues = { ...this.#segmentValues, [segment.type]: next.toString().padStart(segment.len, '0') }; 247 + this.#segmentValues = { 248 + ...this.#segmentValues, 249 + [segment.type]: next.toString().padStart(segment.len, '0'), 250 + }; 220 251 this.#segmentSelected = true; 221 252 this.#pendingTensDigit = null; 222 253 this.#refresh(); ··· 225 256 #onCursor(key?: string) { 226 257 if (!key) return; 227 258 switch (key) { 228 - case 'right': return this.#navigate(1); 229 - case 'left': return this.#navigate(-1); 230 - case 'up': return this.#adjust(1); 231 - case 'down': return this.#adjust(-1); 259 + case 'right': 260 + return this.#navigate(1); 261 + case 'left': 262 + return this.#navigate(-1); 263 + case 'up': 264 + return this.#adjust(1); 265 + case 'down': 266 + return this.#adjust(-1); 232 267 } 233 268 } 234 269 235 270 #onKey(char: string | undefined, key: Key) { 236 271 // Backspace 237 272 const isBackspace = 238 - key?.name === 'backspace' || key?.sequence === '\x7f' || key?.sequence === '\b' || 239 - char === '\x7f' || char === '\b'; 273 + key?.name === 'backspace' || 274 + key?.sequence === '\x7f' || 275 + key?.sequence === '\b' || 276 + char === '\x7f' || 277 + char === '\b'; 240 278 if (isBackspace) { 241 279 this.inlineError = ''; 242 280 const ctx = this.#seg(); ··· 308 346 309 347 const display = this.#segmentValues[segment.type]; 310 348 const firstBlank = display.indexOf('_'); 311 - const pos = firstBlank >= 0 ? firstBlank : Math.min(this.#cursor.positionInSegment, segment.len - 1); 349 + const pos = 350 + firstBlank >= 0 ? firstBlank : Math.min(this.#cursor.positionInSegment, segment.len - 1); 312 351 if (pos < 0 || pos >= segment.len) return; 313 352 314 353 let newVal = display.slice(0, pos) + char + display.slice(pos + 1);
+2 -9
packages/prompts/src/date.ts
··· 77 77 }).prompt() as Promise<Date | symbol>; 78 78 }; 79 79 80 - 81 - function renderDate( 82 - prompt: Omit<InstanceType<typeof DatePrompt>, 'prompt'>, 83 - state: State 84 - ): string { 80 + function renderDate(prompt: Omit<InstanceType<typeof DatePrompt>, 'prompt'>, state: State): string { 85 81 const parts = prompt.segmentValues; 86 82 const cursor = prompt.segmentCursor; 87 83 ··· 103 99 isActive: boolean; 104 100 label: string; 105 101 } 106 - function renderSegment( 107 - value: string, 108 - opts: SegmentOptions, 109 - ): string { 102 + function renderSegment(value: string, opts: SegmentOptions): string { 110 103 const isBlank = !value || value.replace(/_/g, '') === ''; 111 104 if (opts.isActive) return styleText('inverse', isBlank ? opts.label : value.replace(/_/g, ' ')); 112 105 if (isBlank) return styleText('dim', opts.label);