Skip to content

Commit

Permalink
if -> switch
Browse files Browse the repository at this point in the history
  • Loading branch information
schollz committed Sep 14, 2023
1 parent 292dc1e commit 8854a13
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions examples/gno.land/r/demo/keystore/keystore.gno
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ func Render(p string) string {
args := strings.Split(p, ":")
numArgs := len(args)
if p == "" {
numArgs = 0
}
switch numArgs {
case 0:
if data.Size() == 0 {
return StatusNoDatabases
}
Expand All @@ -147,7 +151,7 @@ func Render(p string) string {
response += ufmt.Sprintf("- [%s](%s:%s) (%d keys)\n", ks.Owner, BaseURL, ks.Owner, ks.Data.Size())
return false
})
} else if numArgs == 1 {
case 1:
owner := args[0]
keystoreInterface, exists := data.Get(owner)
if !exists {
Expand All @@ -161,19 +165,20 @@ func Render(p string) string {
i++
return false
})
} else if numArgs == 2 {
case 2:
owner := args[0]
cmd := args[1]
if cmd == "size" {
return size(owner)
}
} else if numArgs == 3 {
case 3:
owner := args[0]
cmd := args[1]
key := args[2]
if cmd == "get" {
return get(owner, key)
}
}

return response
}

0 comments on commit 8854a13

Please sign in to comment.