(text: string)
| 42 | } |
| 43 | |
| 44 | export function parseGoalCommand(text: string): GoalCommand { |
| 45 | const trimmed = text.trim() |
| 46 | const afterPrefix = trimmed.slice(GOAL_PREFIX.length).trim() |
| 47 | if (afterPrefix.length === 0) { |
| 48 | return { |
| 49 | kind: `error`, |
| 50 | message: `Usage: /goal set <objective> [--tokens N|unlimited] | /goal clear | /goal show | /goal complete`, |
| 51 | } |
| 52 | } |
| 53 | const tokens = tokenize(afterPrefix) |
| 54 | const [subcommand, ...rest] = tokens |
| 55 | switch (subcommand) { |
| 56 | case `set`: |
| 57 | return parseSet(rest) |
| 58 | case `clear`: |
| 59 | return { kind: `clear` } |
| 60 | case `show`: |
| 61 | case `status`: |
| 62 | return { kind: `show` } |
| 63 | case `complete`: |
| 64 | case `done`: |
| 65 | return { kind: `complete` } |
| 66 | default: |
| 67 | return { |
| 68 | kind: `error`, |
| 69 | message: `Unknown subcommand "${subcommand}". Use /goal set, /goal clear, /goal show, or /goal complete.`, |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | function parseSet(rest: Array<string>): GoalCommand { |
| 75 | if (rest.length === 0) { |
no test coverage detected