lotus/cmd/lotus-sim/main.go

64 lines
1.2 KiB
Go
Raw Permalink Normal View History

2021-05-19 00:01:30 +00:00
package main
import (
"context"
2021-05-19 00:01:30 +00:00
"fmt"
"os"
"os/signal"
"syscall"
2021-05-19 00:01:30 +00:00
"github.com/urfave/cli/v2"
logging "github.com/ipfs/go-log/v2"
2021-05-19 00:01:30 +00:00
)
var root []*cli.Command = []*cli.Command{
createSimCommand,
deleteSimCommand,
copySimCommand,
renameSimCommand,
2021-05-19 00:01:30 +00:00
listSimCommand,
runSimCommand,
2021-06-07 22:05:52 +00:00
infoSimCommand,
upgradeCommand,
2021-05-19 00:01:30 +00:00
}
func main() {
if _, set := os.LookupEnv("GOLOG_LOG_LEVEL"); !set {
_ = logging.SetLogLevel("simulation", "DEBUG")
2021-06-16 07:19:35 +00:00
_ = logging.SetLogLevel("simulation-mock", "DEBUG")
2021-05-19 00:01:30 +00:00
}
app := &cli.App{
Name: "lotus-sim",
Usage: "A tool to simulate a network.",
Commands: root,
Writer: os.Stdout,
ErrWriter: os.Stderr,
2021-05-19 00:01:30 +00:00
Flags: []cli.Flag{
&cli.StringFlag{
Name: "repo",
EnvVars: []string{"LOTUS_PATH"},
Hidden: true,
Value: "~/.lotus",
},
&cli.StringFlag{
Name: "simulation",
Aliases: []string{"sim"},
EnvVars: []string{"LOTUS_SIMULATION"},
Value: "default",
},
},
}
ctx, cancel := signal.NotifyContext(context.Background(),
syscall.SIGTERM, syscall.SIGINT, syscall.SIGHUP)
defer cancel()
if err := app.RunContext(ctx, os.Args); err != nil {
2021-05-19 00:01:30 +00:00
fmt.Fprintf(os.Stderr, "Error: %s\n", err)
os.Exit(1)
return
}
}