From 61bdd770f7abc77dfb13d38ae8edc498374eaa59 Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Mon, 31 May 2021 22:24:20 +0200 Subject: [PATCH] ek: add "query QUERY CHANNEL" command --- cmd/ek/main.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cmd/ek/main.go b/cmd/ek/main.go index 1c430c7..e86cc9d 100644 --- a/cmd/ek/main.go +++ b/cmd/ek/main.go @@ -138,6 +138,7 @@ Commands: timeline UID -before BEFORE show posts for channel UID ending at BEFORE search QUERY search for feeds from QUERY + query QUERY CHANNEL search for items matching QUERY in CHANNEL preview URL show items from the feed at URL @@ -299,6 +300,24 @@ func performCommands(sub microsub.Microsub, commands []string) { } } + if len(commands) >= 2 && len(commands) <= 3 && commands[0] == "query" { + query := commands[1] + var channel string + if len(commands) == 3 { + channel = commands[2] + } else { + channel = "global" + } + items, err := sub.ItemSearch(channel, query) + if err != nil { + log.Fatalf("An error occurred: %s\n", err) + } + + for _, item := range items { + showItem(&item) + } + } + if len(commands) == 2 && commands[0] == "preview" { u := commands[1] timeline, err := sub.PreviewURL(u)