MCPcopy Create free account
hub / github.com/arctic-cli/interface / wrapText

Function wrapText

packages/arctic/src/cli/ui.ts:131–148  ·  view source on GitHub ↗
(value: string, width: number)

Source from the content-addressed store, hash-verified

129 }
130
131 function wrapText(value: string, width: number) {
132 if (!value) return [""]
133 const words = value.split(" ")
134 const lines: string[] = []
135 let current = ""
136 for (const word of words) {
137 const attempt = current ? `${current} ${word}` : word
138 if (stripAnsi(attempt).length <= width) {
139 current = attempt
140 continue
141 }
142 if (current) lines.push(current)
143 current = word
144 }
145 if (current) lines.push(current)
146 if (!lines.length) lines.push("")
147 return lines
148 }
149
150 export async function input(prompt: string): Promise<string> {
151 const readline = require("readline")

Callers 1

buildLinesFunction · 0.85

Calls 2

stripAnsiFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected