Added Plates and Items Models and connected them with the Frontend
This commit is contained in:
@@ -3,8 +3,10 @@ package cmd
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"printer.backend/internal/model"
|
||||
"printer.backend/internal/svgtemplate"
|
||||
)
|
||||
|
||||
@@ -22,12 +24,27 @@ var generateTemplateCmd = &cobra.Command{
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
data := svgtemplate.Build(sizeFlag, bleedFlag, marginFlag, paddingFlag)
|
||||
|
||||
outPath := filepath.Join(svgtemplate.OutputDir, filepath.Base(outputFlag))
|
||||
base := filepath.Base(outputFlag)
|
||||
outPath := filepath.Join(svgtemplate.OutputDir, base)
|
||||
if err := svgtemplate.WriteFile(outputFlag, data); err != nil {
|
||||
return fmt.Errorf("write svg: %w", err)
|
||||
}
|
||||
|
||||
spec := model.ItemSpec{
|
||||
SizeMM: sizeFlag,
|
||||
BleedMM: bleedFlag,
|
||||
MarginMM: marginFlag,
|
||||
PaddingMM: paddingFlag,
|
||||
}
|
||||
name := strings.TrimSuffix(base, filepath.Ext(base))
|
||||
item, err := svgtemplate.WriteMeta(base, spec, name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("write meta: %w", err)
|
||||
}
|
||||
|
||||
metaPath := filepath.Join(svgtemplate.OutputDir, model.MetaFilename(base))
|
||||
cmd.Printf("Template erfolgreich generiert: %s\n", outPath)
|
||||
cmd.Printf("Item-Metadaten gespeichert: %s (Item %s)\n", metaPath, item.ID)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user