MCPcopy Create free account
hub / github.com/Effect-TS/effect / renderChoicePrefix

Function renderChoicePrefix

packages/effect/src/unstable/cli/Prompt.ts:3124–3152  ·  view source on GitHub ↗
(
  state: SelectState,
  choices: SelectOptionsReq<A>["choices"],
  toDisplay: { readonly startIndex: number; readonly endIndex: number },
  currentIndex: number,
  figures: Effect.Success<typeof platformFigures>,
  renderOptions?: RenderOptions | undefined
)

Source from the content-addressed store, hash-verified

3122}
3123
3124const renderChoicePrefix = <A>(
3125 state: SelectState,
3126 choices: SelectOptionsReq<A>["choices"],
3127 toDisplay: { readonly startIndex: number; readonly endIndex: number },
3128 currentIndex: number,
3129 figures: Effect.Success<typeof platformFigures>,
3130 renderOptions?: RenderOptions | undefined
3131) => {
3132 let prefix = " "
3133 if (currentIndex === toDisplay.startIndex && toDisplay.startIndex > 0) {
3134 prefix = figures.arrowUp
3135 } else if (currentIndex === toDisplay.endIndex - 1 && toDisplay.endIndex < choices.length) {
3136 prefix = figures.arrowDown
3137 }
3138 if (renderOptions?.plain === true) {
3139 return state === currentIndex
3140 ? figures.pointer + prefix
3141 : prefix + " "
3142 }
3143 if (choices[currentIndex].disabled) {
3144 const annotation = Ansi.combine(Ansi.bold, Ansi.blackBright)
3145 return state === currentIndex
3146 ? Ansi.annotate(figures.pointer, annotation) + prefix
3147 : prefix + " "
3148 }
3149 return state === currentIndex
3150 ? Ansi.annotate(figures.pointer, Ansi.cyanBright) + prefix
3151 : prefix + " "
3152}
3153
3154const renderAutoCompleteChoicePrefix = <A>(
3155 state: AutoCompleteState,

Callers 1

renderSelectChoicesFunction · 0.85

Calls 2

combineMethod · 0.65
annotateMethod · 0.65

Tested by

no test coverage detected