36 lines
793 B
Go
36 lines
793 B
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
"gitea.maximumdirect.net/eric/audita/v3/internal/core/config"
|
|
ck "go.maximumdirect.net/configkit"
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
type selectedConfig struct {
|
|
Path string
|
|
Source string
|
|
Result *ck.Result[config.Config]
|
|
}
|
|
|
|
func selectedReportDir(cfg config.Config, outputPath string, reportDirSet bool) (string, error) {
|
|
if !cfg.Reporting.Enabled {
|
|
return "", nil
|
|
}
|
|
var reportDir string
|
|
if outputPath != "" {
|
|
if reportDirSet {
|
|
reportDir = cfg.Reporting.StdoutDir
|
|
} else {
|
|
reportDir = filepath.Dir(outputPath)
|
|
}
|
|
} else {
|
|
reportDir = cfg.Reporting.StdoutDir
|
|
}
|
|
if strings.TrimSpace(reportDir) == "" {
|
|
return "", fmt.Errorf("report directory is required when reporting is enabled for the selected destination")
|
|
}
|
|
return reportDir, nil
|
|
}
|