mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import {
|
|
buildLinearIssueLinkUpdates,
|
|
LINEAR_ISSUE_LINK_CLEARED,
|
|
type LinearIssueLinkUpdates
|
|
} from '../../shared/linear/links'
|
|
import { RuntimeClientError } from '../runtime/types'
|
|
import { getOptionalWorktreeLinkFlagValue } from './worktree-link-flag-value'
|
|
|
|
export function getOptionalLinearIssueLinkFlag(
|
|
flags: Map<string, string | boolean>,
|
|
name: string,
|
|
options: { allowNull?: boolean } = {}
|
|
): LinearIssueLinkUpdates | undefined {
|
|
const value = getOptionalWorktreeLinkFlagValue(flags, name, {
|
|
...options,
|
|
createHint: 'a Linear issue identifier or URL'
|
|
})
|
|
if (value === undefined) {
|
|
return undefined
|
|
}
|
|
|
|
if (value === null) {
|
|
return { ...LINEAR_ISSUE_LINK_CLEARED }
|
|
}
|
|
|
|
// Only literal null unlinks; blank flag values must not inherit the text-field builder's clear behavior.
|
|
const updates = value.trim() === '' ? null : buildLinearIssueLinkUpdates(value)
|
|
if (!updates) {
|
|
throw new RuntimeClientError(
|
|
'invalid_argument',
|
|
'Pass a Linear issue identifier like STA-335, a Linear issue URL, or null to clear.'
|
|
)
|
|
}
|
|
|
|
return updates
|
|
}
|