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