mirror of
https://github.com/stablyai/orca.git
synced 2026-11-01 01:27:35 +00:00
Expose and validate the existing workspace link fields, preserving omitted values and provider identity checks. Related: https://github.com/stablyai/orca/pull/22609 Co-authored-by: marco song <marco.song@mvlchain.io> Co-authored-by: SongMarco <20613630+SongMarco@users.noreply.github.com> Co-authored-by: Luca Critelli <lucacri@gmail.com> Co-authored-by: Neil <neil@stably.ai>
26 lines
757 B
TypeScript
26 lines
757 B
TypeScript
import { RuntimeClientError } from '../runtime-client'
|
|
|
|
export function getOptionalWorktreeLinkFlagValue(
|
|
flags: Map<string, string | boolean>,
|
|
name: string,
|
|
options: { allowNull?: boolean; createHint?: string } = {}
|
|
): string | null | undefined {
|
|
if (!flags.has(name)) {
|
|
return undefined
|
|
}
|
|
const value = flags.get(name)
|
|
if (typeof value !== 'string' || value.length === 0) {
|
|
throw new RuntimeClientError('invalid_argument', `Missing value for --${name}`)
|
|
}
|
|
if (value.trim().toLowerCase() !== 'null') {
|
|
return value
|
|
}
|
|
if (!options.allowNull) {
|
|
throw new RuntimeClientError(
|
|
'invalid_argument',
|
|
`Omit --${name} on create, or pass ${options.createHint ?? 'a valid link reference'}.`
|
|
)
|
|
}
|
|
return null
|
|
}
|