2026-09-24 01:38:49 +00:00
|
|
|
package cli
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
2026-10-11 01:40:38 +00:00
|
|
|
"gitea.maximumdirect.net/eric/audita/v3/internal/core/config"
|
2026-11-10 16:08:53 +00:00
|
|
|
ck "go.maximumdirect.net/configkit"
|
2026-11-10 16:55:56 +00:00
|
|
|
"path/filepath"
|
|
|
|
|
"strings"
|
2026-09-24 01:38:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type selectedConfig struct {
|
|
|
|
|
Path string
|
|
|
|
|
Source string
|
|
|
|
|
Result *ck.Result[config.Config]
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-03 13:46:50 +00:00
|
|
|
func selectedReportDir(cfg config.Config, outputPath string, reportDirSet bool) (string, error) {
|
2026-09-24 17:27:11 +00:00
|
|
|
if !cfg.Reporting.Enabled {
|
|
|
|
|
return "", nil
|
|
|
|
|
}
|
2026-10-03 13:46:50 +00:00
|
|
|
var reportDir string
|
2026-09-24 21:48:18 +00:00
|
|
|
if outputPath != "" {
|
2026-10-03 13:46:50 +00:00
|
|
|
if reportDirSet {
|
|
|
|
|
reportDir = cfg.Reporting.StdoutDir
|
|
|
|
|
} else {
|
|
|
|
|
reportDir = filepath.Dir(outputPath)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
reportDir = cfg.Reporting.StdoutDir
|
2026-09-24 17:27:11 +00:00
|
|
|
}
|
2026-10-03 13:46:50 +00:00
|
|
|
if strings.TrimSpace(reportDir) == "" {
|
|
|
|
|
return "", fmt.Errorf("report directory is required when reporting is enabled for the selected destination")
|
2026-09-24 17:27:11 +00:00
|
|
|
}
|
2026-10-03 13:46:50 +00:00
|
|
|
return reportDir, nil
|
2026-09-24 17:27:11 +00:00
|
|
|
}
|