[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.

feat: add defaultValue option

Nate Moore (Feb 17, 2023, 4:45 AM -0600) 41b5d5ca 7fb53757

+7 -1
+1 -1
.changeset/eleven-pumpkins-refuse.md
··· 3 3 "@clack/core": patch 4 4 --- 5 5 6 - Do not automatically default value to placeholder 6 + Adds a new `defaultValue` option to the text prompt, removes automatic usage of the placeholder value.
+4
packages/core/src/prompts/text.ts
··· 3 3 4 4 export interface TextOptions extends PromptOptions<TextPrompt> { 5 5 placeholder?: string; 6 + defaultValue?: string; 6 7 } 7 8 8 9 export default class TextPrompt extends Prompt { ··· 14 15 super(opts); 15 16 16 17 this.on('finalize', () => { 18 + if (!this.value) { 19 + this.value = opts.defaultValue; 20 + } 17 21 this.valueWithCursor = this.value; 18 22 }); 19 23 this.on('value', () => {
+2
packages/prompts/src/index.ts
··· 45 45 export interface TextOptions { 46 46 message: string; 47 47 placeholder?: string; 48 + defaultValue?: string; 48 49 initialValue?: string; 49 50 validate?: (value: string) => string | void; 50 51 } ··· 52 53 return new TextPrompt({ 53 54 validate: opts.validate, 54 55 placeholder: opts.placeholder, 56 + defaultValue: opts.defaultValue, 55 57 initialValue: opts.initialValue, 56 58 render() { 57 59 const title = `${color.gray(S_BAR)}\n${symbol(this.state)} ${