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:
parent
a5a58dfd32
commit
1c3cfd106c
30
main.go
30
main.go
@ -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,15 +93,30 @@ 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) {
|
||||||
feeds, err := client.Feeds()
|
if len(os.Args) < 3 {
|
||||||
if err != nil {
|
feeds, err := client.Feeds()
|
||||||
fmt.Println(err)
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, feed := range feeds {
|
||||||
|
fmt.Printf("%d\t%s\n", feed.ID, feed.Title)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
} else if len(os.Args) > 3 {
|
||||||
for _, feed := range feeds {
|
fmt.Println("Too many arguments provided!")
|
||||||
fmt.Printf("%d\t%s\n", feed.ID, feed.Title)
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user