cmd/mbf: dump IR of artifact presets

This exposes IR outside test cases, useful for verifying correctness of alternative IR emitters.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-02-07 17:21:43 +09:00
parent ffd2f979fb
commit 096a25ad3a

View File

@@ -150,24 +150,50 @@ func main() {
}, },
) )
c.NewCommand( {
"cure", var (
"Cure the named artifact and show its path", flagDump string
func(args []string) error { )
if len(args) != 1 { c.NewCommand(
return errors.New("cure requires 1 argument") "cure",
} "Cure the named artifact and show its path",
if p, ok := rosa.ResolveName(args[0]); !ok { func(args []string) error {
return fmt.Errorf("unsupported artifact %q", args[0]) if len(args) != 1 {
} else { return errors.New("cure requires 1 argument")
pathname, _, err := cache.Cure(rosa.Std.Load(p))
if err == nil {
log.Println(pathname)
} }
return err if p, ok := rosa.ResolveName(args[0]); !ok {
} return fmt.Errorf("unsupported artifact %q", args[0])
}, } else if flagDump == "" {
) pathname, _, err := cache.Cure(rosa.Std.Load(p))
if err == nil {
log.Println(pathname)
}
return err
} else {
f, err := os.OpenFile(
flagDump,
os.O_WRONLY|os.O_CREATE|os.O_EXCL,
0644,
)
if err != nil {
return err
}
if err = cache.EncodeAll(f, rosa.Std.Load(p)); err != nil {
_ = f.Close()
return err
}
return f.Close()
}
},
).
Flag(
&flagDump,
"dump", command.StringFlag(""),
"Write IR to specified pathname and terminate",
)
}
c.MustParse(os.Args[1:], func(err error) { c.MustParse(os.Args[1:], func(err error) {
if cache != nil { if cache != nil {