feat: add list server command (#2314)
This commit is contained in:
1 parent
f0f7cfbbed
commit
59a27bbaed
5 files changed
+36
-6
No files matched your search
@@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|||||||
|
|
||||||
## r41 (Unreleased)
|
## r41 (Unreleased)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- A new server command `list` is added to print the IDs of all currently connected clients (#2314).
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- A bug where sixel images fail to display when scrolling back and forth is now fixed (#2301).
|
- A bug where sixel images fail to display when scrolling back and forth is now fixed (#2301).
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ Same as **-print-selection**, but write the newline-separated list to *path* ins
|
|||||||
|
|
||||||
**-remote** *command*
|
**-remote** *command*
|
||||||
|
|
||||||
Send *command* to the running server (e.g. `send`, `query` or `quit`). See `REMOTE COMMANDS` for more details.
|
Send *command* to the running server (i.e. `send`, `query`, `list`, `quit`, or `quit!`). See `REMOTE COMMANDS` for more details.
|
||||||
|
|
||||||
**-server**
|
**-server**
|
||||||
|
|
||||||
@@ -1777,6 +1777,10 @@ For example, to select a previous command using fzf and execute it:
|
|||||||
lf -remote "send $id $cmd"
|
lf -remote "send $id $cmd"
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
The `list` command prints the IDs of all currently connected clients:
|
||||||
|
|
||||||
|
lf -remote 'list'
|
||||||
|
|
||||||
There is also a `quit` command to quit the server when there are no connected clients left, and a `quit!` command to force quit the server by closing client connections first:
|
There is also a `quit` command to quit the server when there are no connected clients left, and a `quit!` command to force quit the server by closing client connections first:
|
||||||
|
|
||||||
lf -remote 'quit'
|
lf -remote 'quit'
|
||||||
|
|||||||
@@ -91,8 +91,8 @@ SERVER
|
|||||||
|
|
||||||
-remote command
|
-remote command
|
||||||
|
|
||||||
Send command to the running server (e.g. send, query or quit). See
|
Send command to the running server (i.e. send, query, list, quit, or
|
||||||
REMOTE COMMANDS for more details.
|
quit!). See REMOTE COMMANDS for more details.
|
||||||
|
|
||||||
-server
|
-server
|
||||||
|
|
||||||
@@ -1960,6 +1960,10 @@ For example, to select a previous command using fzf and execute it:
|
|||||||
lf -remote "send $id $cmd"
|
lf -remote "send $id $cmd"
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
The list command prints the IDs of all currently connected clients:
|
||||||
|
|
||||||
|
lf -remote 'list'
|
||||||
|
|
||||||
There is also a quit command to quit the server when there are no
|
There is also a quit command to quit the server when there are no
|
||||||
connected clients left, and a quit! command to force quit the server by
|
connected clients left, and a quit! command to force quit the server by
|
||||||
closing client connections first:
|
closing client connections first:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
.\" Automatically generated by Pandoc 3.7.0.2
|
.\" Automatically generated by Pandoc 3.7.0.2
|
||||||
.\"
|
.\"
|
||||||
.TH "LF" "1" "2025\-12\-10" "r40" "DOCUMENTATION"
|
.TH "LF" "1" "2025\-12\-21" "r41" "DOCUMENTATION"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
lf \- terminal file manager
|
lf \- terminal file manager
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@@ -88,8 +88,9 @@ list to \f[I]path\f[R] instead of stdout.
|
|||||||
.SS SERVER
|
.SS SERVER
|
||||||
.TP
|
.TP
|
||||||
\f[B]\-remote\f[R] \f[I]command\f[R]
|
\f[B]\-remote\f[R] \f[I]command\f[R]
|
||||||
Send \f[I]command\f[R] to the running server (e.g.
|
Send \f[I]command\f[R] to the running server (i.e.
|
||||||
\f[CR]send\f[R], \f[CR]query\f[R] or \f[CR]quit\f[R]).
|
\f[CR]send\f[R], \f[CR]query\f[R], \f[CR]list\f[R], \f[CR]quit\f[R], or
|
||||||
|
\f[CR]quit!\f[R]).
|
||||||
See \f[CR]REMOTE COMMANDS\f[R] for more details.
|
See \f[CR]REMOTE COMMANDS\f[R] for more details.
|
||||||
.TP
|
.TP
|
||||||
\f[B]\-server\f[R]
|
\f[B]\-server\f[R]
|
||||||
@@ -1849,6 +1850,13 @@ map <a\-h> ${{
|
|||||||
}}
|
}}
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
|
The \f[CR]list\f[R] command prints the IDs of all currently connected
|
||||||
|
clients:
|
||||||
|
.IP
|
||||||
|
.EX
|
||||||
|
lf \-remote \(aqlist\(aq
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
There is also a \f[CR]quit\f[R] command to quit the server when there
|
There is also a \f[CR]quit\f[R] command to quit the server when there
|
||||||
are no connected clients left, and a \f[CR]quit!\f[R] command to force
|
are no connected clients left, and a \f[CR]quit!\f[R] command to force
|
||||||
quit the server by closing client connections first:
|
quit the server by closing client connections first:
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -106,6 +107,15 @@ Loop:
|
|||||||
} else {
|
} else {
|
||||||
echoerr(c, "listen: drop: requires a client id")
|
echoerr(c, "listen: drop: requires a client id")
|
||||||
}
|
}
|
||||||
|
case "list":
|
||||||
|
ids := make([]int, 0, len(gConnList))
|
||||||
|
for id := range gConnList {
|
||||||
|
ids = append(ids, id)
|
||||||
|
}
|
||||||
|
sort.Ints(ids)
|
||||||
|
for _, id := range ids {
|
||||||
|
fmt.Fprintln(c, id)
|
||||||
|
}
|
||||||
case "send":
|
case "send":
|
||||||
if rest != "" {
|
if rest != "" {
|
||||||
word2, rest2 := splitWord(rest)
|
word2, rest2 := splitWord(rest)
|
||||||
|
|||||||
Reference in new issue
Block a user