wip
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/hjbdev/patterm/internal/persist"
|
||||
"github.com/hjbdev/patterm/internal/preset"
|
||||
)
|
||||
|
||||
@@ -202,6 +203,33 @@ func (l *Launcher) LaunchCommandArgv(argv []string, displayName, parentID, workD
|
||||
}, cols, rows)
|
||||
}
|
||||
|
||||
// RestoreCommand re-spawns a persisted top-level command entry. If
|
||||
// the entry has a PresetRef and the preset still exists, the spawn
|
||||
// goes through LaunchCommandPreset (so preset.Env / WorkingDir stay
|
||||
// authoritative). Otherwise the saved argv runs directly via
|
||||
// LaunchCommandArgv with shell=false — entries that were originally
|
||||
// `shell: true` were already wrapped into `["sh","-lc",...]` before
|
||||
// persistence, so re-wrapping isn't needed.
|
||||
//
|
||||
// Returns the freshly minted Child. The caller is responsible for
|
||||
// setting auto-restart back on the returned entry.
|
||||
func (l *Launcher) RestoreCommand(e persist.Entry, presets preset.Set) (*Child, error) {
|
||||
if e.PresetRef != "" {
|
||||
for _, p := range presets.Processes {
|
||||
if p.Name == e.PresetRef {
|
||||
return l.LaunchCommandPreset(p, e.Name, "")
|
||||
}
|
||||
}
|
||||
// Preset has been deleted since the entry was saved. Fall
|
||||
// through to argv-based restore using whatever the saved
|
||||
// command looked like at the time.
|
||||
}
|
||||
if len(e.Argv) == 0 {
|
||||
return nil, fmt.Errorf("restore: entry %s has no argv", e.ID)
|
||||
}
|
||||
return l.LaunchCommandArgv(e.Argv, e.Name, "", e.WorkDir, nil, false)
|
||||
}
|
||||
|
||||
// LaunchTerminal spawns a bare interactive shell. SPEC §7 kind=terminal.
|
||||
// argv defaults to $SHELL -i when empty.
|
||||
func (l *Launcher) LaunchTerminal(argv []string, displayName, parentID, workDir string, env []string) (*Child, error) {
|
||||
|
||||
Reference in New Issue
Block a user