MCPcopy Index your code
hub / github.com/cameri/nostream / runConfigSet

Function runConfigSet

src/cli/commands/config.ts:122–166  ·  view source on GitHub ↗
(
  path: string,
  rawValue: string,
  options: {
    restart?: boolean
    validate?: boolean
    valueType?: ValueType
  } = {},
)

Source from the content-addressed store, hash-verified

120}
121
122export const runConfigSet = async (
123 path: string,
124 rawValue: string,
125 options: {
126 restart?: boolean
127 validate?: boolean
128 valueType?: ValueType
129 } = {},
130): Promise<number> => {
131 const valueType = options.valueType ?? 'inferred'
132
133 const pathIssues = validatePathAgainstDefaults(path)
134 if (pathIssues.length > 0) {
135 logError(pathIssues[0].message)
136 return 1
137 }
138
139 const settings = loadUserSettings() as unknown as Record<string, unknown>
140 const next = setByPath(settings, path, parseTypedValue(rawValue, valueType))
141
142 if (options.validate !== false) {
143 const merged = loadMergedSettings() as unknown as Record<string, unknown>
144 const mergedNext = setByPath(merged, path, getByPath(next, path))
145 const validationIssues = validateSettings(mergedNext as any)
146
147 if (validationIssues.length > 0) {
148 logError('Config update rejected by validation:')
149 for (const issue of validationIssues) {
150 logError(`- ${issue.path}: ${issue.message}`)
151 }
152
153 return 1
154 }
155 }
156
157 saveSettings(next as any)
158
159 logInfo(`Updated ${path}`)
160
161 if (options.restart) {
162 return restartRelay()
163 }
164
165 return 0
166}
167
168export const runConfigValidate = async (): Promise<number> => {
169 const settings = loadMergedSettings()

Callers 3

index.tsFile · 0.90
runGuidedConfigureMenuFunction · 0.90
runConfigureMenuFunction · 0.90

Calls 11

logErrorFunction · 0.90
loadUserSettingsFunction · 0.90
setByPathFunction · 0.90
parseTypedValueFunction · 0.90
loadMergedSettingsFunction · 0.90
getByPathFunction · 0.90
validateSettingsFunction · 0.90
saveSettingsFunction · 0.90
logInfoFunction · 0.90
restartRelayFunction · 0.85

Tested by

no test coverage detected