c42a19f7d3
Make OpenCode authoring responsive and expand the managed skill references. Add conflict-aware import/export, real-provider reference workflows, and tracked V2 generation for reliable budget accounting.
54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
package tui
|
|
|
|
import (
|
|
"fmt"
|
|
"git.a-wan.net/alan/pipelines/internal/runinspect"
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
"os/exec"
|
|
"path/filepath"
|
|
"time"
|
|
)
|
|
|
|
type transferFinishedMsg struct {
|
|
path string
|
|
imported bool
|
|
err error
|
|
}
|
|
|
|
func (m Model) transferPipelines(imported bool) (tea.Model, tea.Cmd) {
|
|
executable, err := runinspect.CLIExecutable()
|
|
if err != nil {
|
|
m.appendLine(err.Error())
|
|
return m, nil
|
|
}
|
|
command := "export"
|
|
path := ""
|
|
args := []string{"--url", m.url}
|
|
if imported {
|
|
command = "import"
|
|
} else {
|
|
path, err = filepath.Abs("pipelines-export-" + time.Now().Format("20060102-150405.000000000") + ".zip")
|
|
if err != nil {
|
|
m.appendLine(err.Error())
|
|
return m, nil
|
|
}
|
|
}
|
|
args = append(args, command)
|
|
if path != "" {
|
|
args = append(args, "--output", path)
|
|
}
|
|
return m, tea.ExecProcess(exec.Command(executable, args...), func(err error) tea.Msg { return transferFinishedMsg{path: path, imported: imported, err: err} })
|
|
}
|
|
|
|
func (m *Model) transferResult(msg transferFinishedMsg) {
|
|
if msg.err != nil {
|
|
m.appendLine(fmt.Sprintf("Pipeline transfer canceled or failed: %v", msg.err))
|
|
return
|
|
}
|
|
if msg.imported {
|
|
m.appendLine("Pipeline import completed; conflicts resolved and version history retained.")
|
|
} else {
|
|
m.appendLine("Export saved: " + msg.path)
|
|
}
|
|
}
|