Files
dify/cli/src/commands/config/set/run.ts
T
2026-06-01 01:32:16 +00:00

21 lines
711 B
TypeScript

import type { ConfigFile } from '@/config/schema'
import type { YamlStore } from '@/store/store'
import { loadConfig } from '@/config/config-loader'
import { setKey } from '@/config/keys'
import { emptyConfig } from '@/config/schema'
import { saveConfig } from '@/store/config-writer'
export type RunConfigSetOptions = {
readonly key: string
readonly value: string
readonly store: YamlStore
}
export function runConfigSet(opts: RunConfigSetOptions): string {
const loaded = loadConfig(opts.store)
const config: ConfigFile = loaded.found ? loaded.config : emptyConfig()
const next = setKey(config, opts.key, opts.value)
saveConfig(opts.store, next)
return `set ${opts.key} = ${opts.value}\n`
}