diff --git a/cmd/main.go b/cmd/main.go index 864c802..65efd2c 100644 --- a/cmd/main.go +++ b/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) + } } } diff --git a/pkg/communicator/communicator.go b/pkg/communicator/communicator.go index e1cce68..5dbdc63 100644 --- a/pkg/communicator/communicator.go +++ b/pkg/communicator/communicator.go @@ -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.") + } +} diff --git a/pkg/eraser/eraser.go b/pkg/eraser/eraser.go index d25d7c7..8841581 100644 --- a/pkg/eraser/eraser.go +++ b/pkg/eraser/eraser.go @@ -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) } } }