[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

natemoo-re and committed by
github-actions[bot]
(Feb 5, 2025, 5:30 AM UTC) 251518bd a38b2bc6

+28 -23
+16 -14
examples/basic/stream.ts
··· 9 9 10 10 p.intro(`${color.bgCyan(color.black(' create-app '))}`); 11 11 12 - await p.stream.step((async function* () { 13 - for (const line of lorem) { 14 - for (const word of line.split(' ')) { 15 - yield word; 16 - yield ' '; 17 - await setTimeout(200); 18 - } 19 - yield '\n'; 20 - if (line !== lorem.at(-1)) { 21 - await setTimeout(1000); 12 + await p.stream.step( 13 + (async function* () { 14 + for (const line of lorem) { 15 + for (const word of line.split(' ')) { 16 + yield word; 17 + yield ' '; 18 + await setTimeout(200); 19 + } 20 + yield '\n'; 21 + if (line !== lorem.at(-1)) { 22 + await setTimeout(1000); 23 + } 22 24 } 23 - } 24 - })()) 25 + })() 26 + ); 25 27 26 28 p.outro(`Problems? ${color.underline(color.cyan('https://example.com/issues'))}`); 27 29 } 28 30 29 31 const lorem = [ 30 - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', 32 + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', 31 33 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.', 32 - ] 34 + ]; 33 35 34 36 main().catch(console.error);
+12 -9
packages/prompts/src/index.ts
··· 677 677 678 678 const prefix = `${color.gray(S_BAR)} `; 679 679 export const stream = { 680 - message: async (iterable: Iterable<string>|AsyncIterable<string>, { symbol = color.gray(S_BAR) }: LogMessageOptions = {}) => { 680 + message: async ( 681 + iterable: Iterable<string> | AsyncIterable<string>, 682 + { symbol = color.gray(S_BAR) }: LogMessageOptions = {} 683 + ) => { 681 684 process.stdout.write(`${color.gray(S_BAR)}\n${symbol} `); 682 685 let lineWidth = 3; 683 686 for await (let chunk of iterable) { ··· 686 689 lineWidth = 3 + strip(chunk.slice(chunk.lastIndexOf('\n'))).length; 687 690 } 688 691 const chunkLen = strip(chunk).length; 689 - if ((lineWidth + chunkLen) < process.stdout.columns) { 692 + if (lineWidth + chunkLen < process.stdout.columns) { 690 693 lineWidth += chunkLen; 691 694 process.stdout.write(chunk); 692 695 } else { ··· 696 699 } 697 700 process.stdout.write('\n'); 698 701 }, 699 - info: (iterable: Iterable<string>|AsyncIterable<string>) => { 702 + info: (iterable: Iterable<string> | AsyncIterable<string>) => { 700 703 return stream.message(iterable, { symbol: color.blue(S_INFO) }); 701 704 }, 702 - success: (iterable: Iterable<string>|AsyncIterable<string>) => { 705 + success: (iterable: Iterable<string> | AsyncIterable<string>) => { 703 706 return stream.message(iterable, { symbol: color.green(S_SUCCESS) }); 704 707 }, 705 - step: (iterable: Iterable<string>|AsyncIterable<string>) => { 708 + step: (iterable: Iterable<string> | AsyncIterable<string>) => { 706 709 return stream.message(iterable, { symbol: color.green(S_STEP_SUBMIT) }); 707 710 }, 708 - warn: (iterable: Iterable<string>|AsyncIterable<string>) => { 711 + warn: (iterable: Iterable<string> | AsyncIterable<string>) => { 709 712 return stream.message(iterable, { symbol: color.yellow(S_WARN) }); 710 713 }, 711 714 /** alias for `log.warn()`. */ 712 - warning: (iterable: Iterable<string>|AsyncIterable<string>) => { 715 + warning: (iterable: Iterable<string> | AsyncIterable<string>) => { 713 716 return stream.warn(iterable); 714 717 }, 715 - error: (iterable: Iterable<string>|AsyncIterable<string>) => { 718 + error: (iterable: Iterable<string> | AsyncIterable<string>) => { 716 719 return stream.message(iterable, { symbol: color.red(S_ERROR) }); 717 720 }, 718 - } 721 + }; 719 722 720 723 export const spinner = () => { 721 724 const frames = unicode ? ['◒', '◐', '◓', '◑'] : ['•', 'o', 'O', '0'];