Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ flue relay status # show the configured relay
flue relay update # redeploy this release's relay; secret and pairings kept
flue relay address # repoint this machine at a custom domain on the same relay
flue serve # run the daemon in the foreground, no login service
flue update # download the newest release, swap this binary, restart the daemon
flue version # print the version (also --version, -v)
```

Expand Down
14 changes: 14 additions & 0 deletions cmd/flue/enable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ import (
type fakeManager struct {
st service.Status
enableErr error
restartErr error
warns []string // what Warnings reports after Enable
onRestart func() // runs inside Restart, before it reports back
enableCalls int
disableCalls int
restartCalls int
statusCalls int
}

Expand All @@ -35,6 +38,17 @@ func (f *fakeManager) Disable() error {
f.st = service.Status{}
return nil
}
func (f *fakeManager) Restart() error {
f.restartCalls++
if f.restartErr != nil {
return f.restartErr
}
if f.onRestart != nil {
f.onRestart()
}
f.st = service.Status{Installed: true, Running: true}
return nil
}
func (f *fakeManager) Status() (service.Status, error) {
f.statusCalls++
return f.st, nil
Expand Down
3 changes: 3 additions & 0 deletions cmd/flue/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ func main() {
err = cmdStatus()
case "relay":
err = cmdRelay(os.Args[2:])
case "update":
err = cmdUpdate()
case "version", "--version", "-v":
err = cmdVersion()
case "-h", "--help", "help":
Expand All @@ -110,6 +112,7 @@ const usageText = `flue — your terminal, as a browser tab
flue relay address URL repoint this machine at a custom domain on the same relay
flue open [path] spawn a session in path and open it in the browser
flue serve [--port N] [--open] run the daemon in the foreground
flue update download the newest release, swap this binary, restart the daemon
flue version print the version (also --version, -v)
`

Expand Down
9 changes: 7 additions & 2 deletions cmd/flue/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,14 @@ func (c *releaseChecker) refresh(ctx context.Context) {
if err != nil {
return
}
c.latest, c.url = tag, url
c.latest, c.url = strings.TrimPrefix(tag, "v"), url
}

// fetch asks GitHub for the latest stable release. The tag comes back raw —
// leading v and all — because it is the release's address: flue update builds
// download URLs under /releases/download/<tag>/ from it, exactly as
// install.sh does. Callers that want a version to compare or render trim the
// v themselves, as refresh does for the cache.
func (c *releaseChecker) fetch(ctx context.Context) (tag, url string, err error) {
res, err := c.get(ctx, releaseAPI)
if err != nil {
Expand All @@ -136,7 +141,7 @@ func (c *releaseChecker) fetch(ctx context.Context) (tag, url string, err error)
if body.Draft || body.Pre {
return "", "", fmt.Errorf("latest release is not a stable one")
}
return strings.TrimPrefix(body.TagName, "v"), body.HTMLURL, nil
return body.TagName, body.HTMLURL, nil
}

// newer says whether `latest` is a later release than `current`.
Expand Down
Loading