ads1_2021/code/golang/main.go

79 lines
1.8 KiB
Go

package main
/* ---------------------------------------------------------------- *
* IMPORTS
* ---------------------------------------------------------------- */
import (
"embed"
"os"
"ads/internal/core/logging"
"ads/internal/endpoints"
"ads/internal/setup"
"ads/internal/setup/cli"
"ads/internal/types"
)
/* ---------------------------------------------------------------- *
* GLOBAL VARIABLES
* ---------------------------------------------------------------- */
var (
// !!! NOTE: do not remove the following "comment", as it is a preprocessing instruction !!!
//go:embed assets/*
res embed.FS
assets = map[string]string{
"appconfig": "assets/config.yml",
"version": "assets/VERSION",
"logo": "assets/LOGO",
"help": "assets/HELP",
}
)
/* ---------------------------------------------------------------- *
* METHOD main
* ---------------------------------------------------------------- */
func main() {
var err error
var arguments *types.CliArguments
// assets festlegen
setup.Res = res
setup.Assets = assets
// cli arguments parsen
arguments, err = cli.ParseCli(os.Args)
// initialisiere basic optionen wie Logging
if err == nil {
logging.SetQuietMode(arguments.QuietModeOn())
logging.SetDebugMode(arguments.DebugModeOn())
logging.SetAnsiMode(arguments.ShowColour())
}
// app config (intern) intialisieren
if err == nil {
err = setup.AppConfigInitialise()
}
if err == nil {
setup.AppConfig.Options.Checks = arguments.ShowChecks()
}
if err == nil {
if arguments.Version.Happened() {
endpoints.Version()
} else if arguments.Run.Happened() {
err = endpoints.Run(arguments.GetConfigFile())
} else { // } else if arguments.Help.Happened() {
endpoints.Help()
}
}
if err != nil {
logging.LogFatal(err)
}
}