land/cmd/land/main.go

37 lines
712 B
Go
Raw Permalink Normal View History

2018-06-07 22:31:01 +00:00
package main
2018-06-08 00:08:00 +00:00
import (
"context"
"flag"
2018-06-08 02:02:12 +00:00
"fmt"
2018-06-08 00:08:00 +00:00
"os"
"github.com/Xe/ln"
)
func main() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
flag.Parse()
if flag.NArg() != 1 {
ln.Fatal(ctx, ln.Info("please pass a webassembly file to run"))
}
fname := flag.Arg(0)
fin, err := os.Open(fname)
if err != nil {
ln.FatalErr(ctx, err, ln.F{"msg": "can't open file", "fname": fname})
}
defer fin.Close()
2018-06-18 01:48:10 +00:00
p, err := NewProcess(fin, fname)
2018-06-08 00:08:00 +00:00
if err != nil {
ln.FatalErr(ctx, err, ln.F{"msg": "can't create process", "fname": fname})
}
2018-06-08 02:02:12 +00:00
returnCode, err := p.Main()
2018-06-08 01:21:13 +00:00
2018-06-08 02:02:12 +00:00
ln.Log(ctx, ln.Info("process returned code"), ln.F{"code": returnCode, "type": fmt.Sprintf("%T", returnCode)})
2018-06-08 00:08:00 +00:00
}