// Copyright 2023 schukai GmbH
// SPDX-License-Identifier: AGPL-3.0

package environment

import (
	"github.com/gookit/color"
	"gitlab.schukai.com/oss/utilities/documentation-manager/translations"
	"strings"
)

func PrintMessages() {

	const indent = "  "

	if len(State.errors) > 0 {
		color.Error.Println(strings.ToUpper(translations.T.Sprintf("Error")) + ":")
	}

	for _, message := range State.errors {
		color.Error.Println(indent + message)
	}

	if len(State.warnings) > 0 {
		color.Warn.Println(strings.ToUpper(translations.T.Sprintf("Warn")) + ":")
	}

	for _, message := range State.warnings {
		color.Warn.Println(indent + message)
	}

	if len(State.messages) > 0 {
		color.Info.Println(strings.ToUpper(translations.T.Sprintf("Info")) + ":")
	}

	for _, message := range State.messages {
		color.Info.Println(indent + message)
	}

	// reset
	State.messages = []string{}
	State.warnings = []string{}
	State.errors = []string{}

}