(input: string)
| 57 | * parseCommandInput('init something') // => null |
| 58 | */ |
| 59 | export function parseCommandInput(input: string): ParsedCommandInput | null { |
| 60 | const trimmed = input.trim() |
| 61 | if (!trimmed) return null |
| 62 | |
| 63 | if (trimmed.startsWith('/')) { |
| 64 | const command = parseCommand(trimmed) |
| 65 | if (!command) return null |
| 66 | const args = trimmed.slice(1 + command.length).trim() |
| 67 | return { command, args, implicitCommand: false } |
| 68 | } |
| 69 | |
| 70 | if (/\s/.test(trimmed)) { |
| 71 | return null |
| 72 | } |
| 73 | |
| 74 | const normalized = trimmed.toLowerCase() |
| 75 | if (!SLASHLESS_COMMAND_IDS.has(normalized)) { |
| 76 | return null |
| 77 | } |
| 78 | |
| 79 | return { command: normalized, args: '', implicitCommand: true } |
| 80 | } |
no test coverage detected