(args: string)
| 24 | * - "foo 'hello world' baz" => ["foo", "hello world", "baz"] |
| 25 | */ |
| 26 | export function parseArguments(args: string): string[] { |
| 27 | if (!args || !args.trim()) { |
| 28 | return [] |
| 29 | } |
| 30 | |
| 31 | // Return $KEY to preserve variable syntax literally (don't expand variables) |
| 32 | const result = tryParseShellCommand(args, key => `$${key}`) |
| 33 | if (!result.success) { |
| 34 | // Fall back to simple whitespace split if parsing fails |
| 35 | return args.split(/\s+/).filter(Boolean) |
| 36 | } |
| 37 | |
| 38 | // Filter to only string tokens (ignore shell operators, etc.) |
| 39 | return result.tokens.filter( |
| 40 | (token): token is string => typeof token === 'string', |
| 41 | ) |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Parse argument names from the frontmatter 'arguments' field. |
no test coverage detected