MCPcopy Index your code
hub / github.com/bombshell-dev/clack / render

Function render

packages/prompts/src/password.ts:56–90  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

54 input: opts.input,
55 output: opts.output,
56 render() {
57 const hasGuide = opts.withGuide ?? settings.withGuide;
58 const title = `${hasGuide ? `${styleText('gray', S_BAR)}\n` : ''}${symbol(this.state)} ${opts.message}\n`;
59 const userInput = this.userInputWithCursor;
60 const masked = this.masked;
61
62 switch (this.state) {
63 case 'error': {
64 const errorPrefix = hasGuide ? `${styleText('yellow', S_BAR)} ` : '';
65 const errorPrefixEnd = hasGuide ? `${styleText('yellow', S_BAR_END)} ` : '';
66 const maskedText = masked ?? '';
67 if (opts.clearOnError) {
68 this.clear();
69 }
70 return `${title.trim()}\n${errorPrefix}${maskedText}\n${errorPrefixEnd}${styleText('yellow', this.error)}\n`;
71 }
72 case 'submit': {
73 const submitPrefix = hasGuide ? `${styleText('gray', S_BAR)} ` : '';
74 const maskedText = masked ? styleText('dim', masked) : '';
75 return `${title}${submitPrefix}${maskedText}`;
76 }
77 case 'cancel': {
78 const cancelPrefix = hasGuide ? `${styleText('gray', S_BAR)} ` : '';
79 const maskedText = masked ? styleText(['strikethrough', 'dim'], masked) : '';
80 return `${title}${cancelPrefix}${maskedText}${
81 masked && hasGuide ? `\n${styleText('gray', S_BAR)}` : ''
82 }`;
83 }
84 default: {
85 const defaultPrefix = hasGuide ? `${styleText('cyan', S_BAR)} ` : '';
86 const defaultPrefixEnd = hasGuide ? styleText('cyan', S_BAR_END) : '';
87 return `${title}${defaultPrefix}${userInput}\n${defaultPrefixEnd}\n`;
88 }
89 }
90 },
91 }).prompt() as Promise<string | symbol>;
92};

Callers

nothing calls this directly

Calls 2

symbolFunction · 0.85
clearMethod · 0.65

Tested by

no test coverage detected