cli vm: add default config if nothing passed

Supply VM console with default config.

Close #3450

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
This commit is contained in:
Ekaterina Pavlova 2024-06-06 13:49:00 +03:00
parent c3705664c2
commit 950f35de34

View file

@ -6,6 +6,7 @@ import (
"github.com/chzyer/readline" "github.com/chzyer/readline"
"github.com/nspcc-dev/neo-go/cli/cmdargs" "github.com/nspcc-dev/neo-go/cli/cmdargs"
"github.com/nspcc-dev/neo-go/cli/config"
"github.com/nspcc-dev/neo-go/cli/options" "github.com/nspcc-dev/neo-go/cli/options"
"github.com/nspcc-dev/neo-go/pkg/core/storage/dbconfig" "github.com/nspcc-dev/neo-go/pkg/core/storage/dbconfig"
"github.com/urfave/cli" "github.com/urfave/cli"
@ -27,10 +28,13 @@ func startVMPrompt(ctx *cli.Context) error {
if err := cmdargs.EnsureNone(ctx); err != nil { if err := cmdargs.EnsureNone(ctx); err != nil {
return err return err
} }
var err error
cfg, err := options.GetConfigFromContext(ctx) cfg := config.VM
if err != nil { if ctx.String("config-file") != "" || ctx.String("config-path") != "" {
return cli.NewExitError(err, 1) cfg, err = options.GetConfigFromContext(ctx)
if err != nil {
return cli.NewExitError(err, 1)
}
} }
if ctx.NumFlags() == 0 { if ctx.NumFlags() == 0 {
cfg.ApplicationConfiguration.DBConfiguration.Type = dbconfig.InMemoryDB cfg.ApplicationConfiguration.DBConfiguration.Type = dbconfig.InMemoryDB