feat(lotus-sim): add commands to rename and copy
This commit is contained in:
parent
4f0b9eefc1
commit
bb4753ffbf
24
cmd/lotus-sim/copy.go
Normal file
24
cmd/lotus-sim/copy.go
Normal file
@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var copySimCommand = &cli.Command{
|
||||
Name: "copy",
|
||||
ArgsUsage: "<new-name>",
|
||||
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)
|
||||
},
|
||||
}
|
@ -14,7 +14,10 @@ import (
|
||||
var root []*cli.Command = []*cli.Command{
|
||||
createSimCommand,
|
||||
deleteSimCommand,
|
||||
copySimCommand,
|
||||
renameSimCommand,
|
||||
listSimCommand,
|
||||
|
||||
runSimCommand,
|
||||
infoSimCommand,
|
||||
upgradeCommand,
|
||||
|
24
cmd/lotus-sim/rename.go
Normal file
24
cmd/lotus-sim/rename.go
Normal file
@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var renameSimCommand = &cli.Command{
|
||||
Name: "rename",
|
||||
ArgsUsage: "<new-name>",
|
||||
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)
|
||||
},
|
||||
}
|
Loading…
Reference in New Issue
Block a user