MCPcopy Index your code
hub / github.com/codeaashu/claude-code / extractCommandArguments

Function extractCommandArguments

src/utils/bash/parser.ts:189–222  ·  view source on GitHub ↗
(commandNode: Node)

Source from the content-addressed store, hash-verified

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

Callers 1

getCommandPrefixStaticFunction · 0.85

Calls 3

stripQuotesFunction · 0.85
hasMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected