MCPcopy Index your code
hub / github.com/Effect-TS/effect / renderInput

Function renderInput

packages/cli/src/internal/prompt/text.ts:66–95  ·  view source on GitHub ↗
(nextState: State, options: Options, submitted: boolean)

Source from the content-addressed store, hash-verified

64}
65
66function renderInput(nextState: State, options: Options, submitted: boolean) {
67 const text = getValue(nextState, options)
68
69 const annotation = Option.match(nextState.error, {
70 onNone: () => {
71 if (submitted) {
72 return Ansi.white
73 }
74
75 if (nextState.value.length === 0) {
76 return Ansi.blackBright
77 }
78
79 return Ansi.combine(Ansi.underlined, Ansi.cyanBright)
80 },
81 onSome: () => Ansi.red
82 })
83
84 switch (options.type) {
85 case "hidden": {
86 return Doc.empty
87 }
88 case "password": {
89 return Doc.annotate(Doc.text("*".repeat(text.length)), annotation)
90 }
91 case "text": {
92 return Doc.annotate(Doc.text(text), annotation)
93 }
94 }
95}
96
97function renderError(nextState: State, pointer: Doc.AnsiDoc) {
98 return Option.match(nextState.error, {

Callers 1

renderOutputFunction · 0.70

Calls 4

getValueFunction · 0.85
combineMethod · 0.65
annotateMethod · 0.65
textMethod · 0.45

Tested by

no test coverage detected