make parsing feeds into function
This commit is contained in:
		
							parent
							
								
									9dd67e684c
								
							
						
					
					
						commit
						b331955266
					
				
							
								
								
									
										17
									
								
								cmd/root.go
								
								
								
								
							
							
						
						
									
										17
									
								
								cmd/root.go
								
								
								
								
							| 
						 | 
				
			
			@ -37,12 +37,7 @@ func formatItem(item *gofeed.Item, tmpl *template.Template) (string, error) {
 | 
			
		|||
	return html.UnescapeString(b.String()), err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func rssfetch(cmd *cobra.Command, urls []string) {
 | 
			
		||||
	tmpl, err := template.New("out").Parse(output)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
func parseFeeds(urls []string) []*gofeed.Feed {
 | 
			
		||||
	fp := gofeed.NewParser()
 | 
			
		||||
	var feedChs []chan *gofeed.Feed
 | 
			
		||||
	for _, url := range urls {
 | 
			
		||||
| 
						 | 
				
			
			@ -62,6 +57,16 @@ func rssfetch(cmd *cobra.Command, urls []string) {
 | 
			
		|||
		feeds = append(feeds, <-feedCh)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return feeds
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func rssfetch(cmd *cobra.Command, urls []string) {
 | 
			
		||||
	tmpl, err := template.New("out").Parse(output)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	feeds := parseFeeds(urls)
 | 
			
		||||
	for _, feed := range feeds {
 | 
			
		||||
		for _, item := range feed.Items {
 | 
			
		||||
			out, err := formatItem(item, tmpl)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue