ekster/pkg/rss/debug.go

40 lines
584 B
Go
Raw Permalink Normal View History

2018-04-06 23:29:15 +00:00
// go run debug.go [URL]
// +build ignore
package main
import (
"bytes"
"encoding/json"
"fmt"
"os"
"path/filepath"
"github.com/pstuifzand/go-parse-feed"
)
func main() {
if len(os.Args) != 2 || os.Args[1] == "-h" {
fmt.Fprintf(os.Stderr, "Usage:\n\t%s [URL]\n", filepath.Base(os.Args[0]))
os.Exit(2)
}
feed, err := rss.Fetch(os.Args[1])
if err != nil {
panic(err)
}
raw, err := json.Marshal(feed)
if err != nil {
panic(err)
}
buf := new(bytes.Buffer)
if err := json.Indent(buf, raw, "", "\t"); err != nil {
panic(err)
}
fmt.Println(buf.String())
}