rwho: sort entries
Some checks failed
Build and test / check (push) Failing after 1m8s
Build and test / build (push) Successful in 1m26s
Build and test / test (push) Successful in 2m56s
Build and test / docs (push) Successful in 3m22s

This commit is contained in:
2026-01-06 01:27:06 +09:00
parent 83437588c9
commit 458dc3150c

View File

@@ -34,12 +34,19 @@ async fn main() -> anyhow::Result<()> {
.await
.expect("Failed to connect to rwhod server");
let reply = conn
let mut reply = conn
.rwho(args.all)
.await
.context("Failed to send rwho request")?
.map_err(|e| anyhow::anyhow!("Server returned an error for rwho request: {:?}", e))?;
reply.sort_by(|(host, user), (host2, user2)| {
user.user_id
.cmp(&user2.user_id)
.then_with(|| host.cmp(host2))
.then_with(|| user.tty.cmp(&user2.tty))
});
if args.json {
println!("{}", serde_json::to_string_pretty(&reply).unwrap());
} else if args.old {