2021-05-19 00:01:30 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-06-08 21:22:16 +00:00
|
|
|
"context"
|
2021-05-19 00:01:30 +00:00
|
|
|
"fmt"
|
|
|
|
"os"
|
2021-06-08 21:22:16 +00:00
|
|
|
"os/signal"
|
|
|
|
"syscall"
|
2021-05-19 00:01:30 +00:00
|
|
|
|
2021-06-10 02:40:00 +00:00
|
|
|
logging "github.com/ipfs/go-log/v2"
|
2022-06-14 15:00:51 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
2021-05-19 00:01:30 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var root []*cli.Command = []*cli.Command{
|
|
|
|
createSimCommand,
|
|
|
|
deleteSimCommand,
|
2021-06-08 20:43:39 +00:00
|
|
|
copySimCommand,
|
|
|
|
renameSimCommand,
|
2021-05-19 00:01:30 +00:00
|
|
|
listSimCommand,
|
2021-06-08 20:43:39 +00:00
|
|
|
|
2021-06-07 21:55:39 +00:00
|
|
|
runSimCommand,
|
2021-06-07 22:05:52 +00:00
|
|
|
infoSimCommand,
|
2021-06-07 21:54:20 +00:00
|
|
|
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{
|
2021-06-10 04:56:47 +00:00
|
|
|
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",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-06-08 21:22:16 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|