-
Notifications
You must be signed in to change notification settings - Fork 211
Expand file tree
/
Copy pathupdate.go
More file actions
29 lines (26 loc) · 922 Bytes
/
update.go
File metadata and controls
29 lines (26 loc) · 922 Bytes
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
package cli
import (
"context"
"time"
"github.com/Ehco1996/ehco/internal/constant"
"github.com/Ehco1996/ehco/internal/updater"
cli "github.com/urfave/cli/v2"
)
var UpdateCMD = &cli.Command{
Name: "update",
Usage: "update ehco to the latest GitHub release and restart the systemd service",
Flags: []cli.Flag{
&cli.BoolFlag{Name: "force", Usage: "allow downgrade or channel switch"},
&cli.BoolFlag{Name: "no-restart", Usage: "skip systemctl restart after replacing the binary"},
&cli.StringFlag{Name: "channel", Value: updater.ChannelAuto, Usage: "auto | stable | nightly"},
},
Action: func(c *cli.Context) error {
ctx, cancel := context.WithTimeout(c.Context, 5*time.Minute)
defer cancel()
return updater.Apply(ctx, updater.ApplyOptions{
Channel: c.String("channel"),
Force: c.Bool("force"),
Restart: !c.Bool("no-restart"),
}, constant.Version, constant.GitRevision, cliLogger)
},
}