ads1_2021/code/golang/main.go

69 lines
1.5 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{
"version": "assets/VERSION",
"logo": "assets/LOGO",
"help": "assets/HELP",
}
)
/* ---------------------------------------------------------------- *
* METHOD main
* ---------------------------------------------------------------- */
func main() {
var err error
var arguments *types.CliArguments
// set assets
setup.Res = res
setup.Assets = assets
// parse cli arguments
arguments, err = cli.ParseCli(os.Args)
// initialise logging options
if err == nil {
logging.SetQuietMode(*arguments.Quiet)
logging.SetDebugMode(*arguments.Debug)
logging.SetAnsiMode(arguments.ShowColour())
}
if err == nil {
if arguments.Version.Happened() {
endpoints.Version()
} else if arguments.Run.Happened() {
err = endpoints.Run(*arguments.ConfigFile)
} else { // } else if arguments.Help.Happened() {
endpoints.Help()
}
}
if err != nil {
logging.LogFatal(err)
}
}