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

package environment

import "os"

func (e *stateStruct) GetDocumentDateFormat(arg string) string {
	if arg != "" {
		return arg
	}

	if e.configuration.Document.DateFormat != "" {
		return e.configuration.Document.DateFormat
	}

	return "2006-01-02"

}

func (e *stateStruct) GetDocumentPath(arg string) string {
	if arg != "" {
		return arg
	}

	if e.configuration.Document.Path != "" {
		return e.sanityConfigPath(e.configuration.Document.Path)
	}

	path, err := os.Getwd()
	checkError(err)

	return path
}

func (e *stateStruct) GetDocumentTemplate(arg string) string {

	if arg != "" {
		if t := evaluateTemplate(arg); t != "" {
			return t
		}
	}

	if t := evaluateTemplate(e.configuration.Document.Add.Template); t != "" {
		return t
	}

	return ""

}