refactor: tidy the command's setup, the update command and instance reach (#73)
- main: the subcommand is a name rather than nil-or-empty argument slices; the cache file and start directory are worked out once; config values with a default go through one valueOr helper. - The link handler's --config argument comes from one configArgs helper. - lazysecrets update parses its flags like the other subcommands, so -check and --check=true work too, and tells a development build by its dev version. - Instance reach is named (unreachable, switchable, inView), tmux client activity is compared as a number, and the best client loop starts from the first. - update: serverTimeout (it bounds the checksums request too), and parentheses in the platform check. Reviewed-on: #73 Co-authored-by: Karl-Einar Bergstrøm <karl-einarb@outlook.com>
This commit was merged in pull request #73.
This commit is contained in:
1 parent
fae8e1cbb4
commit
6842c72662
7 files changed
+105
-114
No files matched your search
@@ -35,15 +35,18 @@ func Dir(stateDir string) string {
|
||||
type Status struct {
|
||||
PID int `json:"pid"`
|
||||
LastActive time.Time `json:"lastActive"` // last key press or focus
|
||||
// Reach is how readily it can be shown: 2 in view (outside tmux, or
|
||||
// in a tmux session a client shows), 1 in a tmux session that a tmux
|
||||
// client can be switched to, 0 not at all.
|
||||
Reach int `json:"reach"`
|
||||
Reach int `json:"reach"` // how readily it can be shown: unreachable, switchable or inView
|
||||
// App is the terminal app it would show in (macOS), preferring the
|
||||
// app the link was clicked in.
|
||||
App string `json:"app,omitempty"`
|
||||
}
|
||||
|
||||
const (
|
||||
unreachable = 0
|
||||
switchable = 1 // in a tmux session that a tmux client can be switched to
|
||||
inView = 2 // outside tmux, or in a tmux session a client shows
|
||||
)
|
||||
|
||||
type request struct {
|
||||
Op string `json:"op"` // "status" or "open"
|
||||
Link string `json:"link,omitempty"`
|
||||
@@ -187,7 +190,7 @@ func Best(found []Found, front string, terminal bool) (Found, bool) {
|
||||
best = f
|
||||
}
|
||||
}
|
||||
return best, best.Reach > 0
|
||||
return best, best.Reach > unreachable
|
||||
}
|
||||
|
||||
// Open hands link, clicked in front, to f.
|
||||
|
||||
Reference in new issue
Block a user