package main /* ---------------------------------------------------------------- * * IMPORTS * ---------------------------------------------------------------- */ import ( "embed" "os" "ads/internal/core/logging" "ads/internal/setup" "ads/internal/setup/cli" "ads/internal/types" endpoints_print "ads/internal/endpoints/print" endpoints_run "ads/internal/endpoints/run" ) /* ---------------------------------------------------------------- * * 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 var ( cmdMissing bool showChecks bool ) // assets festlegen setup.Res = res setup.Assets = assets // cli arguments parsen arguments, err = cli.ParseCli(os.Args) cmdMissing = cli.ParseCliCommandMissing(err) // initialisiere basic optionen wie Logging showChecks = false if err == nil { quiet := arguments.QuietModeOn() if arguments.InteractiveMode() { quiet = false } logging.SetQuietMode(quiet) logging.SetDebugMode(arguments.DebugModeOn()) logging.SetAnsiMode(arguments.ShowColour()) showChecks = arguments.ShowChecks() } // app config (intern) intialisieren err = setup.AppConfigInitialise() setup.SetAppConfigPerformChecks(showChecks) if err == nil { if arguments.ModeVersion.Happened() { endpoints_print.Version() } else if arguments.ModeRun.Happened() { if arguments.InteractiveMode() { err = endpoints_run.RunInteractive() } else { err = endpoints_run.RunNonInteractive(arguments.GetConfigFile()) } } else if arguments.ModeHelp.Happened() { endpoints_print.Help() } else { err = endpoints_run.RunInteractive() } } else if cmdMissing { err = endpoints_run.RunInteractive() } if err != nil { logging.LogFatal(err) } }