ek: add "query QUERY CHANNEL" command

This commit is contained in:
Peter Stuifzand 2021-05-31 22:24:20 +02:00
parent 7433947f72
commit 61bdd770f7
Signed by: peter
GPG Key ID: 374322D56E5209E8

View File

@ -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)