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 {
return config.ProfileStatus.Unavailable
}
func AppendOpResult(res *config.PresetResult, r opResult) {
var msg string
func AppendOpResult(res *Result, r opResult) {
item := ui.TreeItem{
Status: r.Status,
}
switch r.Status {
case StatusSkipped:
msg = fmt.Sprintf("Уже существует: %s — пропущено", r.Target)
case StatusDryRun:
msg = fmt.Sprintf("[Dry-run] %s → %s", r.Source, r.Target)
case StatusDone:
msg = fmt.Sprintf("Выполнено: %s → %s", r.Source, r.Target)
case StatusError:
msg = fmt.Sprintf("Ошибка: %s", r.Reason)
switch {
case r.Status.IsEqual(config.OpStatus.Skipped):
item.Name = fmt.Sprintf("Уже существует: %s", r.Target)
case r.Status.IsEqual(config.OpStatus.DryRun):
item.Name = fmt.Sprintf("%s → %s", r.Source, r.Target)
case r.Status.IsEqual(config.OpStatus.Done):
item.Name = fmt.Sprintf("%s → %s", r.Source, r.Target)
case r.Status.IsEqual(config.OpStatus.Error):
item.Name = fmt.Sprintf("Ошибка: %s", r.Reason)
}
switch r.Kind {
case OpCopy:
res.Copies = append(res.Copies, msg)
res.Copies = append(res.Copies, item)
case OpLink:
res.Links = append(res.Links, msg)
res.Links = append(res.Links, item)
}
}
......@@ -78,12 +80,12 @@ func expandPath(path, name string) string {
return path
}
func renderPresetResult(res *config.PresetResult) {
ui.RenderTreeLines("Копируем", res.Copies)
ui.RenderTreeLines("Создаём ссылки", res.Links)
ui.RenderTreeLines("Обновляем", res.Replaced)
ui.RenderTreeLines("Настраиваем систему", res.System)
ui.RenderTreeLines("Создаём переменные Hyprland", res.HyprVars)
ui.RenderTreeLines("Подключаем модули Hyprland", res.HyprModules)
ui.RenderTreeLines("Синхронизируем раскладку Hyprland", res.SyncSystemLayouts)
func renderPresetResult(res *Result) {
ui.RenderTreeItems("Копируем", res.Copies)
ui.RenderTreeItems("Создаём ссылки", res.Links)
ui.RenderTreeItems("Обновляем", res.Replaced)
ui.RenderTreeItems("Настраиваем систему", res.System)
ui.RenderTreeItems("Создаём переменные Hyprland", res.HyprVars)
ui.RenderTreeItems("Подключаем модули Hyprland", res.HyprModules)
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