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

Function renderAutoCompleteChoices

packages/effect/src/unstable/cli/Prompt.ts:3225–3249  ·  view source on GitHub ↗
(
  state: AutoCompleteState,
  options: AutoCompleteOptionsReq<A>,
  figures: Effect.Success<typeof platformFigures>,
  renderOptions?: RenderOptions | undefined
)

Source from the content-addressed store, hash-verified

3223}
3224
3225const renderAutoCompleteChoices = <A>(
3226 state: AutoCompleteState,
3227 options: AutoCompleteOptionsReq<A>,
3228 figures: Effect.Success<typeof platformFigures>,
3229 renderOptions?: RenderOptions | undefined
3230) => {
3231 if (state.filtered.length === 0) {
3232 return renderOptions?.plain === true
3233 ? options.emptyMessage
3234 : Ansi.annotate(options.emptyMessage, Ansi.blackBright)
3235 }
3236 const cursor = autoCompleteCursor(state)
3237 const toDisplay = entriesToDisplay(cursor, state.filtered.length, options.maxPerPage)
3238 const documents: Array<string> = []
3239 for (let index = toDisplay.startIndex; index < toDisplay.endIndex; index++) {
3240 const choiceIndex = state.filtered[index]
3241 const choice = options.choices[choiceIndex]
3242 const isSelected = state.index === choiceIndex
3243 const prefix = renderAutoCompleteChoicePrefix(state, options, toDisplay, index, figures, renderOptions)
3244 const title = renderChoiceTitle(choice, isSelected, renderOptions)
3245 const description = renderChoiceDescription(choice, isSelected, renderOptions)
3246 documents.push(prefix + title + " " + description)
3247 }
3248 return documents.join("\n")
3249}
3250
3251const renderSelectNextFrame = Effect.fnUntraced(function*<A>(state: SelectState, options: SelectOptionsReq<A>) {
3252 const figures = yield* platformFigures

Callers 2

Prompt.tsFile · 0.85
handleAutoCompleteClearFunction · 0.85

Calls 8

autoCompleteCursorFunction · 0.85
entriesToDisplayFunction · 0.85
renderChoiceTitleFunction · 0.85
renderChoiceDescriptionFunction · 0.85
pushMethod · 0.80
joinMethod · 0.80
annotateMethod · 0.65

Tested by

no test coverage detected