MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / extractCommandArguments

Function extractCommandArguments

source code/utils/bash/parser.ts:191–224  ·  view source on GitHub ↗
(commandNode: Node)

Source from the content-addressed store, hash-verified

189}
190
191export function extractCommandArguments(commandNode: Node): string[] {
192 // Declaration commands
193 if (commandNode.type === 'declaration_command') {
194 const firstChild = commandNode.children[0]
195 return firstChild && DECLARATION_COMMANDS.has(firstChild.text)
196 ? [firstChild.text]
197 : []
198 }
199
200 const args: string[] = []
201 let foundCommandName = false
202
203 for (const child of commandNode.children) {
204 if (child.type === 'variable_assignment') continue
205
206 // Command name
207 if (
208 child.type === 'command_name' ||
209 (!foundCommandName && child.type === 'word')
210 ) {
211 foundCommandName = true
212 args.push(child.text)
213 continue
214 }
215
216 // Arguments
217 if (ARGUMENT_TYPES.has(child.type)) {
218 args.push(stripQuotes(child.text))
219 } else if (SUBSTITUTION_TYPES.has(child.type)) {
220 break
221 }
222 }
223 return args
224}
225
226function stripQuotes(text: string): string {
227 return text.length >= 2 &&

Callers 1

getCommandPrefixStaticFunction · 0.85

Calls 2

stripQuotesFunction · 0.85
hasMethod · 0.45

Tested by

no test coverage detected