Commit e64e7d14 authored by Kirill Unitsaev's avatar Kirill Unitsaev

preset: integrate status indicators into result output

parent 6eeca1f8
...@@ -34,25 +34,27 @@ func profileStatus(p config.PresetProfile) config.ItemStatus { ...@@ -34,25 +34,27 @@ func profileStatus(p config.PresetProfile) config.ItemStatus {
return config.ProfileStatus.Unavailable return config.ProfileStatus.Unavailable
} }
func AppendOpResult(res *config.PresetResult, r opResult) { func AppendOpResult(res *Result, r opResult) {
var msg string item := ui.TreeItem{
Status: r.Status,
}
switch r.Status { switch {
case StatusSkipped: case r.Status.IsEqual(config.OpStatus.Skipped):
msg = fmt.Sprintf("Уже существует: %s — пропущено", r.Target) item.Name = fmt.Sprintf("Уже существует: %s", r.Target)
case StatusDryRun: case r.Status.IsEqual(config.OpStatus.DryRun):
msg = fmt.Sprintf("[Dry-run] %s → %s", r.Source, r.Target) item.Name = fmt.Sprintf("%s → %s", r.Source, r.Target)
case StatusDone: case r.Status.IsEqual(config.OpStatus.Done):
msg = fmt.Sprintf("Выполнено: %s → %s", r.Source, r.Target) item.Name = fmt.Sprintf("%s → %s", r.Source, r.Target)
case StatusError: case r.Status.IsEqual(config.OpStatus.Error):
msg = fmt.Sprintf("Ошибка: %s", r.Reason) item.Name = fmt.Sprintf("Ошибка: %s", r.Reason)
} }
switch r.Kind { switch r.Kind {
case OpCopy: case OpCopy:
res.Copies = append(res.Copies, msg) res.Copies = append(res.Copies, item)
case OpLink: case OpLink:
res.Links = append(res.Links, msg) res.Links = append(res.Links, item)
} }
} }
...@@ -78,12 +80,12 @@ func expandPath(path, name string) string { ...@@ -78,12 +80,12 @@ func expandPath(path, name string) string {
return path return path
} }
func renderPresetResult(res *config.PresetResult) { func renderPresetResult(res *Result) {
ui.RenderTreeLines("Копируем", res.Copies) ui.RenderTreeItems("Копируем", res.Copies)
ui.RenderTreeLines("Создаём ссылки", res.Links) ui.RenderTreeItems("Создаём ссылки", res.Links)
ui.RenderTreeLines("Обновляем", res.Replaced) ui.RenderTreeItems("Обновляем", res.Replaced)
ui.RenderTreeLines("Настраиваем систему", res.System) ui.RenderTreeItems("Настраиваем систему", res.System)
ui.RenderTreeLines("Создаём переменные Hyprland", res.HyprVars) ui.RenderTreeItems("Создаём переменные Hyprland", res.HyprVars)
ui.RenderTreeLines("Подключаем модули Hyprland", res.HyprModules) ui.RenderTreeItems("Подключаем модули Hyprland", res.HyprModules)
ui.RenderTreeLines("Синхронизируем раскладку Hyprland", res.SyncSystemLayouts) ui.RenderTreeItems("Синхронизируем раскладку Hyprland", res.SyncSystemLayouts)
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment