* Build the diff scope from CLI input. `--pr` resolves the base/head from a * GitHub PR and so can't be combined with the local-ref selectors.
(refs: string[], opts: DiffCommandOptions)
| 34 | * GitHub PR and so can't be combined with the local-ref selectors. |
| 35 | */ |
| 36 | function toDiffScopeOptions(refs: string[], opts: DiffCommandOptions): DiffScopeOptions { |
| 37 | if (opts.pr !== undefined) { |
| 38 | if ( |
| 39 | refs.length > 0 || |
| 40 | opts.base !== undefined || |
| 41 | opts.compare !== undefined || |
| 42 | opts.ref !== undefined |
| 43 | ) { |
| 44 | throw new Error("--pr cannot be combined with git refs, --base, --compare, or --ref."); |
| 45 | } |
| 46 | return { pr: opts.pr }; |
| 47 | } |
| 48 | const workingTreeRef = |
| 49 | opts.ref !== undefined ? z.enum(WORKING_TREE_REF).parse(opts.ref) : undefined; |
| 50 | return { base: opts.base, compare: opts.compare, refs, workingTreeRef }; |
| 51 | } |
| 52 | |
| 53 | program |
| 54 | .command("prep") |