From 3144da86f39b5c3409912ed8ffe05f49172769b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Kripalani?= Date: Thu, 29 Jul 2021 13:49:47 +0100 Subject: [PATCH] add RepoType#String; adjust repo parsing logic. --- cli/util/api.go | 4 +++- node/repo/fsrepo.go | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/cli/util/api.go b/cli/util/api.go index c6e3ae9be..bf34f4421 100644 --- a/cli/util/api.go +++ b/cli/util/api.go @@ -124,7 +124,9 @@ func GetAPIInfo(ctx *cli.Context, t repo.RepoType) (APIInfo, error) { repoFlags := flagsForRepo(t) for _, f := range repoFlags { - if !ctx.IsSet(f) { + // cannot use ctx.IsSet because it ignores default values + f := ctx.String(f) + if f == "" { continue } diff --git a/node/repo/fsrepo.go b/node/repo/fsrepo.go index d3e6f4f2f..5c1c91bc5 100644 --- a/node/repo/fsrepo.go +++ b/node/repo/fsrepo.go @@ -52,6 +52,21 @@ const ( Markets ) +func (t RepoType) String() string { + s := [...]string{ + "__invalid__", + "FullNode", + "StorageMiner", + "Worker", + "Wallet", + "Markets", + } + if t < 0 || int(t) > len(s) { + return "__invalid__" + } + return s[t] +} + func defConfForType(t RepoType) interface{} { switch t { case FullNode: