Files
br ca6cdcca63 software steht so weit.
jetzt build + docker build und testen
2026-10-02 13:25:34 +02:00

53 lines
1.2 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package cli
import (
"errors"
"flag"
"fmt"
"io"
"sultan/pkg/lander"
)
type dumpOptions struct {
dir string
force bool
}
func parseDumpFlags(args []string, output io.Writer) (dumpOptions, error) {
fs := flag.NewFlagSet("sultan dump-landing", flag.ContinueOnError)
fs.SetOutput(output)
var o dumpOptions
fs.StringVar(&o.dir, "out", "./suldata/landing", "Zielverzeichnis (der Server liest <data-dir>/landing)")
fs.BoolVar(&o.force, "force", false, "vorhandene Dateien überschreiben")
if err := fs.Parse(args); err != nil {
return o, err
}
if fs.NArg() > 0 {
return o, fmt.Errorf("unerwartetes Argument %q", fs.Arg(0))
}
return o, nil
}
// runDump schreibt die eingebauten Lander-Seiten als Vorlagen zum Anpassen.
func runDump(args []string, stdout, stderr io.Writer) int {
o, err := parseDumpFlags(args, stderr)
if errors.Is(err, flag.ErrHelp) {
return 0
}
if err != nil {
fmt.Fprintln(stderr, err)
return 2
}
files, err := lander.Dump(o.dir, o.force)
if err != nil {
fmt.Fprintln(stderr, "Fehler:", err)
return 1
}
for _, f := range files {
fmt.Fprintln(stdout, f)
}
fmt.Fprintln(stderr, "Vorlagen geschrieben – Änderungen wirken sofort, ohne Neustart (siehe README.txt).")
return 0
}