MCPcopy Index your code
hub / github.com/anomalyco/opencode / pathArgs

Function pathArgs

packages/opencode/src/tool/shell.ts:188–218  ·  view source on GitHub ↗
(list: Part[], ps: boolean, cmd = false)

Source from the content-addressed store, hash-verified

186}
187
188function pathArgs(list: Part[], ps: boolean, cmd = false) {
189 if (!ps) {
190 return list
191 .slice(1)
192 .filter(
193 (item) =>
194 !item.text.startsWith("-") &&
195 !(cmd && item.text.startsWith("/")) &&
196 !(list[0]?.text === "chmod" && item.text.startsWith("+")),
197 )
198 .map((item) => item.text)
199 }
200
201 const out: string[] = []
202 let want = false
203 for (const item of list.slice(1)) {
204 if (want) {
205 out.push(item.text)
206 want = false
207 continue
208 }
209 if (item.type === "command_parameter") {
210 const flag = item.text.toLowerCase()
211 if (SWITCHES.has(flag)) continue
212 want = FLAGS.has(flag)
213 continue
214 }
215 out.push(item.text)
216 }
217 return out
218}
219
220function preview(text: string) {
221 if (text.length <= MAX_METADATA_LENGTH) return text

Callers 1

shell.tsFile · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected