-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.go
39 lines (33 loc) · 871 Bytes
/
update.go
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
package main
import (
"os"
"os/exec"
aw "github.com/deanishe/awgo"
)
// doUpdate checks for a newer version of the workflow.
func doUpdate() error {
return wf.CheckForUpdate()
}
// checkForUpdate runs "./alsf update" in the background if an update check is due.
func checkForUpdate() error {
if !wf.UpdateCheckDue() || wf.IsRunning("update") {
return nil
}
cmd := exec.Command(os.Args[0], "update")
return wf.RunInBackground("update", cmd)
}
// showUpdateStatus adds an "update available!" message to Script Filters if an update is available
// and query is empty.
func showUpdateStatus() {
if query != "" {
return
}
if wf.UpdateAvailable() {
wf.Configure(aw.SuppressUIDs(true))
wf.NewItem("An update is available!").
Subtitle("⇥ or ↩ to install update").
Valid(false).
Autocomplete("workflow:update").
Icon(updateAvailable)
}
}