-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrss_cmd.go
61 lines (51 loc) · 1.21 KB
/
rss_cmd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package radikocast
import (
"flag"
"fmt"
"strings"
"github.com/mitchellh/cli"
)
type rssCommand struct {
ui cli.Ui
}
func (c *rssCommand) Run(args []string) int {
var title, host, image, bucket, feed string
f := flag.NewFlagSet("rss", flag.ContinueOnError)
f.StringVar(&title, "title", "", "title")
f.StringVar(&host, "host", "", "host")
f.StringVar(&image, "image", "", "image")
f.StringVar(&bucket, "bucket", "", "bucket")
f.StringVar(&feed, "feed", "", "feed")
f.Usage = func() { c.ui.Error(c.Help()) }
if err := f.Parse(args); err != nil {
c.ui.Error(fmt.Sprintf("Bad args. %s", err))
return 1
}
rss, err := GenerateRss(title, host, image, bucket)
if err != nil {
c.ui.Error(fmt.Sprintf("Failed to generate rss. %s", err))
return 1
}
err = PutRss(rss, bucket, feed)
if err != nil {
c.ui.Error(fmt.Sprintf("Failed to write rss. %s", err))
return 1
}
c.ui.Output(fmt.Sprintf("Updated %s", feed))
return 0
}
func (c *rssCommand) Synopsis() string {
return "Generate podcast RSS"
}
func (c *rssCommand) Help() string {
return strings.TrimSpace(`
Usage: radikocast rss [options]
Generate podcast RSS
Options:
-title title
-host host
-image image
-bucket bucket
-feed feed
`)
}