2021-09-26 10:30:51 +05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-09-28 08:35:03 +05:00
|
|
|
"flag"
|
|
|
|
"fmt"
|
2021-09-26 10:30:51 +05:00
|
|
|
"log"
|
2021-09-28 08:35:03 +05:00
|
|
|
"os"
|
2021-09-26 10:30:51 +05:00
|
|
|
|
|
|
|
"go.dev.pztrn.name/periodicator/internal/config"
|
|
|
|
"go.dev.pztrn.name/periodicator/internal/gitlab"
|
|
|
|
"go.dev.pztrn.name/periodicator/internal/tasks"
|
|
|
|
)
|
|
|
|
|
2021-09-29 07:35:31 +05:00
|
|
|
var (
|
|
|
|
showNextCreationTS = flag.Bool("show-next-creation-ts", false, "Show tasks next creation timestamps")
|
|
|
|
showVersion = flag.Bool("version", false, "Show version information and exit")
|
|
|
|
)
|
2021-09-28 08:35:03 +05:00
|
|
|
|
2021-09-26 10:30:51 +05:00
|
|
|
func main() {
|
2021-09-28 08:35:03 +05:00
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
if *showVersion {
|
|
|
|
// nolint:forbidigo
|
|
|
|
fmt.Println(config.Version)
|
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Println("Starting periodic tasks creator, version " + config.Version + "...")
|
2021-09-26 10:30:51 +05:00
|
|
|
|
|
|
|
cfg := config.Parse()
|
|
|
|
|
2021-11-21 17:38:31 +05:00
|
|
|
gitlabClient := gitlab.NewGitlabClient(&cfg.Gitlab)
|
2021-09-26 10:30:51 +05:00
|
|
|
|
2021-09-29 07:35:31 +05:00
|
|
|
if *showNextCreationTS {
|
2021-11-21 17:38:31 +05:00
|
|
|
tasks.PrintCreationTSes(gitlabClient, cfg.Tasks)
|
2021-09-29 07:35:31 +05:00
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
|
2021-11-21 17:38:31 +05:00
|
|
|
tasks.Process(gitlabClient, cfg.Tasks)
|
2021-09-26 10:30:51 +05:00
|
|
|
}
|