add dry mode
This commit is contained in:
parent
ff6d97bc68
commit
6faa569a56
1 changed files with 7 additions and 1 deletions
|
@ -27,6 +27,7 @@ var opts struct {
|
|||
AccessSecret string `long:"access-secret" env:"ACCESS_SECRET" required:"true" description:"twitter access secret"`
|
||||
|
||||
Template string `long:"template" env:"TEMPLATE" default:"{{.Title}} - {{.Link}}" description:"twitter message template"`
|
||||
Dry bool `long:"dry" env:"DRY" description:"dry mode"`
|
||||
Dbg bool `long:"dbg" env:"DEBUG" description:"debug mode"`
|
||||
}
|
||||
|
||||
|
@ -41,12 +42,17 @@ func main() {
|
|||
setupLog(opts.Dbg)
|
||||
|
||||
notifier := rss.New(context.Background(), opts.Feed, opts.Refresh)
|
||||
pub := publisher.Twitter{
|
||||
var pub publisher.Interface
|
||||
pub = publisher.Twitter{
|
||||
ConsumerKey: opts.ConsumerKey,
|
||||
ConsumerSecret: opts.ConsumerSecret,
|
||||
AccessToken: opts.AccessToken,
|
||||
AccessSecret: opts.AccessSecret,
|
||||
}
|
||||
if opts.Dry {
|
||||
pub = publisher.Stdout{}
|
||||
log.Print("[INFO] dry mode")
|
||||
}
|
||||
|
||||
for event := range notifier.Go() {
|
||||
err := pub.Publish(event, func(r rss.Event) string {
|
||||
|
|
Loading…
Reference in a new issue