Add a --write and --diff flag; require --write to be set before making any changes, for safety

This commit is contained in:
Pim van Pelt
2025-08-28 11:18:59 +02:00
parent 6bc0071bdb
commit d027ec9108
8 changed files with 133 additions and 26 deletions

View File

@@ -76,7 +76,7 @@ type NginxTemplateData struct {
ListenPort string
}
func generateNginx(yamlFile string) {
func generateNginx(yamlFile string, wantDiff bool, allowWrite bool, useColor bool) {
config := loadConfig(yamlFile)
// Extract port from first listen address
@@ -123,7 +123,7 @@ func generateNginx(yamlFile string) {
}
// Write file with status
err = writeFileWithStatus(outputPath, buf.Bytes())
err = writeFileWithStatus(outputPath, buf.Bytes(), wantDiff, allowWrite, useColor)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to write nginx config file %s: %v\n", outputPath, err)
continue