blob: c9825ae9ddc0e1ab79f3b31d83d4ff62c7a1c7f5 (
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
51
52
53
54
55
|
package runner
import (
"pik/identity"
"pik/model"
)
// BaseTarget is an embeddable type which contains some of the information we need for (almost) every target.
type BaseTarget struct {
identity.Identity
MyTags model.Tags
Sub []string
}
func (t *BaseTarget) Tags() model.Tags {
return t.MyTags
}
func (t *BaseTarget) Matches(input string) bool {
return t.Identity.Is(input)
}
func (t *BaseTarget) ShortestId() string {
return t.Reduced
}
func (b *BaseTarget) Visible() bool {
return b.Tags().Visible()
}
func (b *BaseTarget) Invocation(src *model.Source) []string {
return append([]string{src.Identity.Reduced}, append(b.Sub, b.Identity.Reduced)...)
}
func Hydrated[T model.Target](in T) BaseHydration[T] {
return BaseHydration[T]{
Self: in,
}
}
type BaseHydration[T model.Target] struct {
Self T
}
func (b *BaseHydration[T]) Icon() string {
return ""
}
func (b *BaseHydration[T]) Description() string {
return ""
}
func (b *BaseHydration[T]) Target() model.Target {
return b.Self
}
|