forked from cli/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextension.go
More file actions
64 lines (51 loc) · 1.01 KB
/
extension.go
File metadata and controls
64 lines (51 loc) · 1.01 KB
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
56
57
58
59
60
61
62
63
64
package extension
import (
"path/filepath"
"strings"
)
const manifestName = "manifest.yml"
type ExtensionKind int
const (
GitKind ExtensionKind = iota
BinaryKind
)
type Extension struct {
path string
url string
isLocal bool
isPinned bool
currentVersion string
latestVersion string
kind ExtensionKind
}
func (e *Extension) Name() string {
return strings.TrimPrefix(filepath.Base(e.path), "gh-")
}
func (e *Extension) Path() string {
return e.path
}
func (e *Extension) URL() string {
return e.url
}
func (e *Extension) IsLocal() bool {
return e.isLocal
}
func (e *Extension) CurrentVersion() string {
return e.currentVersion
}
func (e *Extension) IsPinned() bool {
return e.isPinned
}
func (e *Extension) UpdateAvailable() bool {
if e.isPinned ||
e.isLocal ||
e.currentVersion == "" ||
e.latestVersion == "" ||
e.currentVersion == e.latestVersion {
return false
}
return true
}
func (e *Extension) IsBinary() bool {
return e.kind == BinaryKind
}