Adding ability to output to stdout instead of Telegram.

This commit is contained in:
Matt Burchett
2020-09-23 10:13:14 -05:00
parent cd44fb971d
commit 42439d61b4
3 changed files with 21 additions and 4 deletions

View File

@ -15,12 +15,14 @@ func main() {
var days int
var sectionID int
var check bool
var text bool
var delete bool
flag.StringVar(&c, "config", "", "Configuration to load")
flag.IntVar(&days, "days", 0, "How many days of inactivity to look for on Plex.")
flag.IntVar(&sectionID, "sectionid", 0, "Plex Section ID")
flag.BoolVar(&check, "check", true, "Perform only a check. This will send the message out to Telegram with what can be removed. Does not delete.")
flag.BoolVar(&text, "check", false, "This will override the communication to Telegram and print to stdout.")
flag.BoolVar(&delete, "delete", false, "Perform the delete task.")
flag.Parse()
@ -42,9 +44,13 @@ func main() {
ids, titles := locator.GetTitles(cfg, sectionID, days)
if check {
err = communicator.TelegramPost(cfg, titles)
if err != nil {
log.Fatal(err)
if text {
communicator.StdoutPost(titles)
} else {
err = communicator.TelegramPost(cfg, titles)
if err != nil {
log.Fatal(err)
}
}
}