summaryrefslogtreecommitdiff
path: root/runner/exc/target.go
blob: c9d20b8ab2bac3624fcc7ba95828b2f1544dbfa8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package exc

import (
	"os/exec"
	"pik/describe"
	"pik/model"
	"pik/runner"
	"pik/spool"
)

type Executable struct {
	runner.BaseTarget
	Path string
}

type Hydrated struct {
	*runner.BaseHydration[*Executable]
}

func (h *Hydrated) Icon() string {
	return "\uEAE8"
}

func (h *Hydrated) Description(src *model.HydratedSource) string {
	d, err := describe.Describe(h.Self, h.Self.Path)
	if err != nil {
		spool.Warn("%v\n", err)
	}
	return d
}

func (e *Executable) Create(s *model.Source) *exec.Cmd {
	return exec.Command(e.Path)
}

func (e *Executable) Label() string {
	return e.Identity.Full
}

func (e *Executable) Hydrate(src *model.Source) (model.HydratedTarget, error) {
	return &Hydrated{
		BaseHydration: &runner.BaseHydration[*Executable]{
			Self: e,
		},
	}, nil
}

func (e *Executable) File(src *model.Source) string {
	return e.Path
}