feat: add list server command - #2314
Conversation
|
Any thoughts on this, @joelim-work? One could also query |
|
What is the practical use case of this exactly? If you need to know the PID of an instance, you can display it in the ruler: As for listing out all the clients, I don't think the server currently has a way of exposing this. I suppose it is fine to add a server command for this, but you could probably achieve the same thing using |
It about convenience. cmd id &{{
lf -remote "send $id echo ${id}"
}}Like I said, my use-case is basically debugging remote commands. Using I do admit, this is a rather niche use case for sure (and so are the profiling flags). Also having a client command instead of just a server command allows showing the list inside this menu right inside Again, I completely get the argument that this might be a specialised, uncommon workflow, that is why I was asking for your input. |
|
OK I thought about this a bit more. Regarding convenience, I would argue that displaying it in the ruler is even more convenient than the using a custom command since it is shown automatically without having to type Regarding listing out all clients, using
diff --git a/server.go b/server.go
index 0055656..9deae0a 100644
--- a/server.go
+++ b/server.go
@@ -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)As for the
Instead, it should be scripted as a custom command in user configuration like this: cmd clients %{{
lf -remote list | while read -r client; do
if [ "$client" = "$id" ]; then
printf '[%s] ' "$client"
else
printf '%s ' "$client"
fi
done
}}I am aware that using |
Fair point.
Done.
Fair point as well. I only thought about the placement in
I am also fine with this. |
clients commandlist server command
c9c6755 to
34a63b3
Compare

This PR adds a new server command
listwhich lists all clients currently connected to the server.