add RepoType#String; adjust repo parsing logic.

This commit is contained in:
Raúl Kripalani 2021-07-29 13:49:47 +01:00 committed by Jennifer Wang
parent 299b106f38
commit b3c951c924
2 changed files with 18 additions and 1 deletions

View File

@ -124,7 +124,9 @@ func GetAPIInfo(ctx *cli.Context, t repo.RepoType) (APIInfo, error) {
repoFlags := flagsForRepo(t) repoFlags := flagsForRepo(t)
for _, f := range repoFlags { for _, f := range repoFlags {
if !ctx.IsSet(f) { // cannot use ctx.IsSet because it ignores default values
f := ctx.String(f)
if f == "" {
continue continue
} }

View File

@ -52,6 +52,21 @@ const (
Markets 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{} { func defConfForType(t RepoType) interface{} {
switch t { switch t {
case FullNode: case FullNode: