feat: add list server command (#2314)

This commit is contained in:
CatsDeservePets authored and GitHub committed 2025-12-21 06:56:43 +01:00
1 parent f0f7cfbbed
commit 59a27bbaed
5 files changed
+36 -6

No files matched your search

+4
View File
@@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
## r41 (Unreleased)
### Added
- A new server command `list` is added to print the IDs of all currently connected clients (#2314).
### Fixed
- A bug where sixel images fail to display when scrolling back and forth is now fixed (#2301).
+5 -1
View File
@@ -86,7 +86,7 @@ Same as **-print-selection**, but write the newline-separated list to *path* ins
**-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**
@@ -1777,6 +1777,10 @@ For example, to select a previous command using fzf and execute it:
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:
lf -remote 'quit'
+6 -2
View File
@@ -91,8 +91,8 @@ SERVER
-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
@@ -1960,6 +1960,10 @@ For example, to select a previous command using fzf and execute it:
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:
+11 -3
View File
@@ -1,6 +1,6 @@
.\" 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
lf \- terminal file manager
.SH SYNOPSIS
@@ -88,8 +88,9 @@ list to \f[I]path\f[R] instead of stdout.
.SS SERVER
.TP
\f[B]\-remote\f[R] \f[I]command\f[R]
Send \f[I]command\f[R] to the running server (e.g.
\f[CR]send\f[R], \f[CR]query\f[R] or \f[CR]quit\f[R]).
Send \f[I]command\f[R] to the running server (i.e.
\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.
.TP
\f[B]\-server\f[R]
@@ -1849,6 +1850,13 @@ map <a\-h> ${{
}}
.EE
.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
are no connected clients left, and a \f[CR]quit!\f[R] command to force
quit the server by closing client connections first:
+10
View File
@@ -6,6 +6,7 @@ import (
"log"
"net"
"os"
"sort"
"strconv"
)
@@ -106,6 +107,15 @@ Loop:
} else {
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":
if rest != "" {
word2, rest2 := splitWord(rest)