Adding ability to output to stdout instead of Telegram.
This commit is contained in:
parent
cd44fb971d
commit
42439d61b4
12
cmd/main.go
12
cmd/main.go
@ -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(§ionID, "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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,3 +46,14 @@ func TelegramPost(config config.Config, titles []string) error {
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// StdoutPost will relay the titles out to stdout.
|
||||
func StdoutPost(titles []string) {
|
||||
if len(titles) != 0 {
|
||||
for _, title := range titles {
|
||||
fmt.Println(title)
|
||||
}
|
||||
} else {
|
||||
fmt.Println("There are no titles. Nothing to display.")
|
||||
}
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ func DeleteFiles(delete bool, files []string) error {
|
||||
fmt.Printf("Removing %v\n", i)
|
||||
err = os.RemoveAll(i)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Println(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user