MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / extractPatternsFromCommand

Function extractPatternsFromCommand

webview-ui/src/utils/command-parser.ts:13–28  ·  view source on GitHub ↗
(command: string)

Source from the content-addressed store, hash-verified

11 * bodies and multi-line opaque tokens are never fed raw to shell-quote.
12 */
13export function extractPatternsFromCommand(command: string): string[] {
14 if (!command?.trim()) return []
15
16 const patterns = new Set<string>()
17
18 // Split into sub-commands using the heredoc- and quote-aware parser so that
19 // constructs like heredocs or unterminated quotes are not broken up by
20 // shell-quote's operator splitting.
21 const { commands: subCommands } = parseCommand(command)
22
23 for (const subCmd of subCommands) {
24 extractPatternsFromSingleCommand(subCmd, patterns)
25 }
26
27 return Array.from(patterns).sort()
28}
29
30/**
31 * Extract patterns from a single sub-command (no chaining operators) using

Callers 2

CommandExecutionFunction · 0.90

Calls 3

parseCommandFunction · 0.90
fromMethod · 0.80

Tested by

no test coverage detected