mirror of
https://github.com/yuaotian/go-cursor-help.git
synced 2025-06-08 12:32:06 +08:00
feat: Improve error handling in configuration modification function
- Added detailed error messages for configuration file modification failures - Enhanced logging to provide specific guidance for manual configuration updates - Maintained existing key replacement and addition logic - Improved user feedback for configuration modification errors
This commit is contained in:
parent
1ac23403e5
commit
89751a79c3
@ -178,12 +178,14 @@ modify_or_add_config() {
|
||||
# key存在,执行替换
|
||||
if ! sed -i '' -e "s/\"$key\":[[:space:]]*\"[^\"]*\"/\"$key\": \"$value\"/" "$file"; then
|
||||
log_error "修改配置失败: $key"
|
||||
log_error "请手动修改配置文件: $file"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
# key不存在,添加新的key-value对
|
||||
if ! sed -i '' -e "s/}$/,\n \"$key\": \"$value\"\n}/" "$file"; then
|
||||
log_error "添加配置失败: $key"
|
||||
log_error "请手动修改配置文件: $file"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user