aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-02-07 17:21:43 +0900
committerOphestra <cat@gensokyo.uk>2026-02-07 17:21:43 +0900
commit096a25ad3a7229931aa57ec4186564c67806d0fe (patch)
treef35affe20b7d94d1c3d7f216e8cabfeada0f4789
parentffd2f979fb620e72611ba718ac9f64f2c59f89a1 (diff)
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>
-rw-r--r--cmd/mbf/main.go60
1 files changed, 43 insertions, 17 deletions
diff --git a/cmd/mbf/main.go b/cmd/mbf/main.go
index 2c10c3ab..db5e80af 100644
--- a/cmd/mbf/main.go
+++ b/cmd/mbf/main.go
@@ -150,24 +150,50 @@ func main() {
},
)
- c.NewCommand(
- "cure",
- "Cure the named artifact and show its path",
- func(args []string) error {
- if len(args) != 1 {
- return errors.New("cure requires 1 argument")
- }
- if p, ok := rosa.ResolveName(args[0]); !ok {
- return fmt.Errorf("unsupported artifact %q", args[0])
- } else {
- pathname, _, err := cache.Cure(rosa.Std.Load(p))
- if err == nil {
- log.Println(pathname)
+ {
+ var (
+ flagDump string
+ )
+ c.NewCommand(
+ "cure",
+ "Cure the named artifact and show its path",
+ func(args []string) error {
+ if len(args) != 1 {
+ return errors.New("cure requires 1 argument")
}
- 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) {
if cache != nil {