(command: Command)
| 7664 | } |
| 7665 | |
| 7666 | function resolveCommonOptions(command: Command): CommonOptions { |
| 7667 | const globals = command.optsWithGlobals() as Partial<CommonOptions> & { |
| 7668 | requestTimeout?: string; |
| 7669 | }; |
| 7670 | // P2-8: validate --output before allowing silent fallback to 'text'. |
| 7671 | // An invalid value (e.g. `--output yaml`) must exit 5 with a clear error |
| 7672 | // rather than silently treating the request as text mode. |
| 7673 | const rawOutput = globals.output; |
| 7674 | if (rawOutput !== undefined && rawOutput !== 'json' && rawOutput !== 'text') { |
| 7675 | throw localValidationError('output', 'must be one of: json, text', ['json', 'text']); |
| 7676 | } |
| 7677 | return { |
| 7678 | profile: globals.profile ?? 'default', |
| 7679 | output: (globals.output as OutputMode | undefined) ?? 'text', |
| 7680 | dryRun: globals.dryRun ?? false, |
| 7681 | endpointUrl: globals.endpointUrl, |
| 7682 | debug: globals.debug ?? false, |
| 7683 | verbose: globals.verbose ?? false, |
| 7684 | requestTimeoutMs: parseRequestTimeoutFlag(globals.requestTimeout), |
| 7685 | }; |
| 7686 | } |
| 7687 | |
| 7688 | /** |
| 7689 | * Parse the `--request-timeout <seconds>` flag value into milliseconds. |
no test coverage detected