| 343 | |
| 344 | // fallow-ignore-next-line complexity |
| 345 | function resolveProjectInput(opts: { |
| 346 | dir: string | undefined; |
| 347 | assetId: string | undefined; |
| 348 | url: string | undefined; |
| 349 | }): ProjectInputSource { |
| 350 | // Count every source the user explicitly supplied. The positional |
| 351 | // `dir` defaults to `undefined` when omitted (not to "."), so we |
| 352 | // can detect "user actually typed something" vs. "default to cwd". |
| 353 | const explicit = { |
| 354 | dir: opts.dir !== undefined && opts.dir !== "", |
| 355 | assetId: opts.assetId !== undefined && opts.assetId !== "", |
| 356 | url: opts.url !== undefined && opts.url !== "", |
| 357 | }; |
| 358 | const count = Number(explicit.dir) + Number(explicit.assetId) + Number(explicit.url); |
| 359 | if (count > 1) { |
| 360 | errorBox("Conflicting inputs", "Pass only one of: project dir, --asset-id, --url."); |
| 361 | process.exit(1); |
| 362 | } |
| 363 | if (explicit.assetId) return { kind: "asset_id", assetId: opts.assetId }; |
| 364 | if (explicit.url) return { kind: "url", url: opts.url }; |
| 365 | return { kind: "dir", dir: opts.dir ?? "." }; |
| 366 | } |
| 367 | |
| 368 | /** |
| 369 | * Resolve the aspect ratio for the submit body, validating local inputs. |