(opts: CLIOptions)
| 27 | } |
| 28 | |
| 29 | export function validateOptions(opts: CLIOptions): ValidatedOptions { |
| 30 | const prompt = opts.prompt; |
| 31 | const promptMode = prompt !== undefined; |
| 32 | if (promptMode && prompt.trim().length === 0) { |
| 33 | throw new OptionConflictError('Prompt cannot be empty.'); |
| 34 | } |
| 35 | if (opts.model !== undefined && opts.model.trim().length === 0) { |
| 36 | throw new OptionConflictError('Model cannot be empty.'); |
| 37 | } |
| 38 | if (!promptMode && opts.outputFormat !== undefined) { |
| 39 | throw new OptionConflictError('Output format is only supported in prompt mode.'); |
| 40 | } |
| 41 | if (promptMode && opts.yolo) { |
| 42 | throw new OptionConflictError('Cannot combine --prompt with --yolo.'); |
| 43 | } |
| 44 | if (promptMode && opts.auto) { |
| 45 | throw new OptionConflictError('Cannot combine --prompt with --auto.'); |
| 46 | } |
| 47 | if (promptMode && opts.plan) { |
| 48 | throw new OptionConflictError('Cannot combine --prompt with --plan.'); |
| 49 | } |
| 50 | if (promptMode && opts.session === '') { |
| 51 | throw new OptionConflictError('Cannot use --session without an id in prompt mode.'); |
| 52 | } |
| 53 | if (opts.continue && opts.session !== undefined) { |
| 54 | throw new OptionConflictError('Cannot combine --continue, --session.'); |
| 55 | } |
| 56 | if (opts.yolo && opts.auto) { |
| 57 | throw new OptionConflictError('Cannot combine --yolo with --auto.'); |
| 58 | } |
| 59 | return { options: opts, uiMode: promptMode ? 'print' : 'shell' }; |
| 60 | } |
no outgoing calls
no test coverage detected