Skip to content

Commit

Permalink
Add --prefix option support for IndexedDB
Browse files Browse the repository at this point in the history
  • Loading branch information
cions committed Nov 7, 2021
1 parent 43d9b16 commit 79fa148
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package leveldbcli

import (
"bytes"
"errors"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -178,29 +177,30 @@ func deleteCmd(c *cli.Context) (err error) {

func getKeyRange(c *cli.Context) (*util.Range, error) {
if c.IsSet("prefix-base64") {
if c.Bool("indexeddb") {
return nil, errors.New("use of --prefix-base64 in conjunction with --indexeddb is not supported")
}
prefix, err := decodeBase64([]byte(c.String("prefix-base64")))
if err != nil {
return nil, fmt.Errorf("option --prefix-base64: %w", err)
}
if c.Bool("indexeddb") {
return indexeddb.Prefix(prefix), nil
}
return util.BytesPrefix(prefix), nil
}
if c.IsSet("prefix-raw") {
prefix := []byte(c.String("prefix-raw"))
if c.Bool("indexeddb") {
return nil, errors.New("use of --prefix-raw in conjunction with --indexeddb is not supported")
return indexeddb.Prefix(prefix), nil
}
return util.BytesPrefix([]byte(c.String("prefix-raw"))), nil
return util.BytesPrefix(prefix), nil
}
if c.IsSet("prefix") {
if c.Bool("indexeddb") {
return nil, errors.New("use of --prefix in conjunction with --indexeddb is not supported")
}
prefix, err := unescape([]byte(c.String("prefix")))
if err != nil {
return nil, fmt.Errorf("option --prefix: %w", err)
}
if c.Bool("indexeddb") {
return indexeddb.Prefix(prefix), nil
}
return util.BytesPrefix(prefix), nil
}

Expand Down

0 comments on commit 79fa148

Please sign in to comment.