Skip to content

Commit

Permalink
template: prefix decode with filename + template name (descriptive)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinlindhe committed Dec 15, 2024
1 parent 8dbdde4 commit 129e2f9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions cmd/feng/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"path/filepath"
"runtime"
"runtime/pprof"
Expand Down Expand Up @@ -125,6 +126,9 @@ func main() {
size := mapper.FileSize(f)
feng.Printf("%s: %s (%s)\n", args.Filename, fl.BaseName, mapper.ByteCountSI(size))
} else {

fmt.Printf("# %s (%s)\n", args.Filename, fl.DS.Name)

fl.Present(&mapper.PresentFileLayoutConfig{
ShowRaw: args.Raw,
ShowInDecimal: args.Decimal,
Expand Down
15 changes: 12 additions & 3 deletions template/datastructures.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import (

// structure of a evaluated ./templates/ yaml file. see Template for the raw structure corresponding to the yaml file
type DataStructure struct {
// Kind of resource, like "image", "archive"
Kind string

// Descriptive name of this template
Name string

// constants derived from eq & bit pattern matches
Constants []Constant
Expand Down Expand Up @@ -79,8 +84,7 @@ func NewDataStructureFrom(template *Template, basename string) (*DataStructure,
log.Warn().Err(err).Msgf("%s: evaluateLayout failed", basename)
return nil, err
}

return &DataStructure{
ds := DataStructure{
Constants: constants,
EvaluatedStructs: structs,
Layout: layout,
Expand All @@ -90,7 +94,12 @@ func NewDataStructureFrom(template *Template, basename string) (*DataStructure,
Extensions: template.Extensions,
Filenames: template.Filenames,
BaseName: basename,
}, nil
}

ds.Name = template.Name
ds.Kind = template.Kind

return &ds, nil
}

// looks up layout name from sections
Expand Down

0 comments on commit 129e2f9

Please sign in to comment.