Add ability to list feeds of a category.

By providing a category id after the feeds command, list the feeds in that category.
This commit is contained in:
CronyAkatsuki 2023-11-11 20:31:35 +01:00
parent a5a58dfd32
commit 1c3cfd106c

18
main.go
View File

@ -13,6 +13,7 @@ import (
// Help message // Help message
const HELP = `examples: const HELP = `examples:
mfeed create {category_id} {feed_url} mfeed create {category_id} {feed_url}
mfeed feeds {category_id}
usage: mfeed [-h] {feeds,categories,create} ... usage: mfeed [-h] {feeds,categories,create} ...
feeds list all the feeds you have feeds list all the feeds you have
@ -92,8 +93,9 @@ func main() {
return return
} }
// Print out all your feeds and their id's // Print out all your feeds and their id's, or feeds in a category if provided
func feeds(client *miniflux.Client) { func feeds(client *miniflux.Client) {
if len(os.Args) < 3 {
feeds, err := client.Feeds() feeds, err := client.Feeds()
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
@ -102,6 +104,20 @@ func feeds(client *miniflux.Client) {
for _, feed := range feeds { for _, feed := range feeds {
fmt.Printf("%d\t%s\n", feed.ID, feed.Title) fmt.Printf("%d\t%s\n", feed.ID, feed.Title)
} }
return
} else if len(os.Args) > 3 {
fmt.Println("Too many arguments provided!")
return
} else {
category, err := strconv.Atoi(os.Args[2])
if err != nil {
panic(err)
}
feeds, err := client.CategoryFeeds(int64(category))
for _, feed := range feeds {
fmt.Printf("%d\t%s\n", feed.ID, feed.Title)
}
}
} }
// Print out all your categories and their id's // Print out all your categories and their id's