feat(tui): 名录编辑器循环 + 挂进 Edit-Config(第三轮第二块·完成)
装配:Get-BakNRetCatalogField → 菜单选字段 → Read-BakNRetLine → Set-BakNRetCatalogField → Save-BakNRetConfigFile(校验通过才原子替换 + 时间戳备份)。 菜单里**只列可编辑的字段**(单行的 Encrypt / Description):把只读的 Path / Exclude 也列出来再拒绝,会让每个只读项浪费用户一次回车。 校验用模块自己的 Import-BaknretDataFile:这份名录有 $( ) 动态表达式与跨行拼接,普通数据文件读取器读不了 —— 而正是它保证"改完整份文件还能被程序读回来"(值能读回来才算改成功)。定位用 (软件名, Slot, 字段名) 三元组,因为同一软件可以有多个 Slot。 Edit-Config 的三个界面(清单 / 设置 / 名录)至此全部完成。 判据 9 条:改一个值后只动一行、注释行数不变、改完能读回新值、留下时间戳备份且备份里是原文;取消时不写盘也不产生备份。 验收:test.ps1 9/9 全绿(5.1 与 7);真实清单只读冒烟 4/4。
This commit is contained in:
1 parent
8c018533c9
commit
effc38fdd3
5 files changed
+151
-2
No files matched your search
+22
-2
@@ -66,8 +66,18 @@ if ($Target -eq 'Settings') {
|
||||
exit 0
|
||||
}
|
||||
|
||||
if ($Target -eq 'Catalog') {
|
||||
$catalogPath = Join-Path $PSScriptRoot 'SoftwareCatalog.psd1'
|
||||
$driver = New-BakNRetInputDriver -Script $InputScript -NonInteractive:$([bool]$InputScript)
|
||||
$saved = Invoke-BakNRetCatalogEditor -Path $catalogPath -Driver $driver
|
||||
if ($saved.Saved) { Write-Host ("已保存:{0}" -f $catalogPath) -ForegroundColor Green; Write-Host ("原文件备份:{0}" -f $saved.BackupPath) -ForegroundColor DarkGray; exit 0 }
|
||||
if ($saved.Error) { Write-Host $saved.Error -ForegroundColor Yellow; exit 1 }
|
||||
Write-Host '没有改动。' -ForegroundColor DarkGray
|
||||
exit 0
|
||||
}
|
||||
|
||||
if ($Target) {
|
||||
Write-Host ("{0} 的编辑器还没做:清单与设置已完成;名录是第三轮的工作。" -f $Target) -ForegroundColor Yellow
|
||||
Write-Host ("{0} 的编辑器还没做:清单 / 设置 / 名录三个界面都已完成。" -f $Target) -ForegroundColor Yellow
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -102,5 +112,15 @@ if ($picked.Chosen.Key -eq 'Settings') {
|
||||
exit 0
|
||||
}
|
||||
|
||||
Write-Host ("{0} 的编辑器还没做(名录是第三轮的工作)。" -f $picked.Chosen.Key) -ForegroundColor Yellow
|
||||
if ($picked.Chosen.Key -eq 'Catalog') {
|
||||
$catalogPath = Join-Path $PSScriptRoot 'SoftwareCatalog.psd1'
|
||||
$driver3 = New-BakNRetInputDriver -Script $InputScript -NonInteractive:$([bool]$InputScript)
|
||||
$saved3 = Invoke-BakNRetCatalogEditor -Path $catalogPath -Driver $driver3
|
||||
if ($saved3.Saved) { Write-Host ("已保存:{0}" -f $catalogPath) -ForegroundColor Green; exit 0 }
|
||||
if ($saved3.Error) { Write-Host $saved3.Error -ForegroundColor Yellow; exit 1 }
|
||||
Write-Host '没有改动。' -ForegroundColor DarkGray
|
||||
exit 0
|
||||
}
|
||||
|
||||
Write-Host ("未知的目标:{0}" -f $picked.Chosen.Key) -ForegroundColor Yellow
|
||||
exit 1
|
||||
Reference in new issue
Block a user