From bb4753ffbfc7ce2a62554d7eddb80b76d1bdad0c Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 8 Jun 2021 13:43:39 -0700 Subject: [PATCH] feat(lotus-sim): add commands to rename and copy --- cmd/lotus-sim/copy.go | 24 ++++++++++++++++++++++++ cmd/lotus-sim/main.go | 3 +++ cmd/lotus-sim/rename.go | 24 ++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 cmd/lotus-sim/copy.go create mode 100644 cmd/lotus-sim/rename.go diff --git a/cmd/lotus-sim/copy.go b/cmd/lotus-sim/copy.go new file mode 100644 index 000000000..eeb8eb1aa --- /dev/null +++ b/cmd/lotus-sim/copy.go @@ -0,0 +1,24 @@ +package main + +import ( + "fmt" + + "github.com/urfave/cli/v2" +) + +var copySimCommand = &cli.Command{ + Name: "copy", + ArgsUsage: "", + Action: func(cctx *cli.Context) error { + node, err := open(cctx) + if err != nil { + return err + } + defer node.Close() + if cctx.NArg() != 1 { + return fmt.Errorf("expected 1 argument") + } + name := cctx.Args().First() + return node.CopySim(cctx.Context, cctx.String("simulation"), name) + }, +} diff --git a/cmd/lotus-sim/main.go b/cmd/lotus-sim/main.go index 8fe313355..cf8903d72 100644 --- a/cmd/lotus-sim/main.go +++ b/cmd/lotus-sim/main.go @@ -14,7 +14,10 @@ import ( var root []*cli.Command = []*cli.Command{ createSimCommand, deleteSimCommand, + copySimCommand, + renameSimCommand, listSimCommand, + runSimCommand, infoSimCommand, upgradeCommand, diff --git a/cmd/lotus-sim/rename.go b/cmd/lotus-sim/rename.go new file mode 100644 index 000000000..833a57e96 --- /dev/null +++ b/cmd/lotus-sim/rename.go @@ -0,0 +1,24 @@ +package main + +import ( + "fmt" + + "github.com/urfave/cli/v2" +) + +var renameSimCommand = &cli.Command{ + Name: "rename", + ArgsUsage: "", + Action: func(cctx *cli.Context) error { + node, err := open(cctx) + if err != nil { + return err + } + defer node.Close() + if cctx.NArg() != 1 { + return fmt.Errorf("expected 1 argument") + } + name := cctx.Args().First() + return node.RenameSim(cctx.Context, cctx.String("simulation"), name) + }, +}