(step: NextStep)
| 35 | } |
| 36 | |
| 37 | function formatNextStepForCli(step: NextStep): string { |
| 38 | const commandName = step.cliTool ?? (step.tool ? toKebabCase(step.tool) : undefined); |
| 39 | if (!commandName) { |
| 40 | return resolveLabel(step); |
| 41 | } |
| 42 | |
| 43 | const parts = ['xcodebuildmcp']; |
| 44 | if (step.workflow) { |
| 45 | parts.push(step.workflow); |
| 46 | } |
| 47 | parts.push(commandName); |
| 48 | |
| 49 | const params = step.params ?? {}; |
| 50 | if (Object.values(params).some(hasComplexCliParamValue)) { |
| 51 | parts.push('--json', formatCliParamValue(params)); |
| 52 | return parts.join(' '); |
| 53 | } |
| 54 | |
| 55 | for (const [key, value] of Object.entries(params)) { |
| 56 | const flagName = toKebabCase(key); |
| 57 | if (typeof value === 'boolean') { |
| 58 | if (value) { |
| 59 | parts.push(`--${flagName}`); |
| 60 | } |
| 61 | } else { |
| 62 | parts.push(`--${flagName}`, formatCliParamValue(value)); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | return parts.join(' '); |
| 67 | } |
| 68 | |
| 69 | function formatMcpValue(value: NextStepParamValue): string { |
| 70 | if (typeof value === 'string' || (typeof value === 'object' && value !== null)) { |
no test coverage detected