-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathmain.go
47 lines (42 loc) · 868 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"context"
"errors"
"fmt"
"os"
"os/signal"
"syscall"
"github.com/ethereum-optimism/asterisc/rvgo/cmd"
"github.com/urfave/cli/v2"
)
func main() {
app := cli.NewApp()
app.Name = "asterisc"
app.Usage = "RISC-V Fault Proof tool"
app.Description = "RISC-V Fault Proof tool"
app.Commands = []*cli.Command{
cmd.LoadELFCommand,
cmd.WitnessCommand,
cmd.RunCommand,
}
ctx, cancel := context.WithCancel(context.Background())
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGINT, syscall.SIGTERM)
go func() {
for {
<-c
cancel()
fmt.Println("\r\nExiting...")
}
}()
err := app.RunContext(ctx, os.Args)
if err != nil {
if errors.Is(err, ctx.Err()) {
_, _ = fmt.Fprintf(os.Stderr, "command interrupted")
os.Exit(130)
} else {
_, _ = fmt.Fprintf(os.Stderr, "error: %v", err)
os.Exit(1)
}
}
}