ilijamt/vht

Case-insensitive search option

Closed this issue · 3 comments

It would be convenient to have an option to specify that the search should be done in a case-insensitive manner. This is helpful when I'm not sure of the case of a key.

You can search case-insensitive even now if you want to. The regex is a Go regex, so if you want to search something that is case-insensitive, try. Here is with the local docker compose vault file.

❯ docker compose up -d
[+] Running 2/2
 ✔ Network vht_default    Created                                                                                                                                                      ✔ Container vht-vault-1  Started                                                                                                                                                     

❯ export VAULT_ADDR='http://127.0.0.1:8200'
❯ export VAULT_TOKEN=token

❯ vault secrets enable -version=2 -path kv2 kv
Success! Enabled the kv secrets engine at: kv2/

❯ export KV_DATE=$(date +%s) 
❯ vault kv put kv2/aBbA timestamp=$KV_DATE value=abba
❯ vault kv put kv2/abba/cAAb/qaz timestamp=$KV_DATE value=qaz
❯ vault kv put kv2/new value=aBbA
❯ vault kv put kv2/nEw value=abba

❯ vht tree -r kv2
kv2/aBbA
kv2/nEw
kv2/new
kv2/abba/cAAb/qaz

❯ vht tree -r kv2 -k 'abba'
kv2/abba/cAAb/qaz

❯ vht tree -r kv2 -k '(?i)abba'
kv2/aBbA
kv2/abba/cAAb/qaz

❯ vht search -r kv2 -d -f '(?i)abba'
kv2/aBbA
kv2/nEw
kv2/new

❯ vht search -r kv2 -d -f 'abba'
kv2/aBbA
kv2/nEw

Does this work for you @jschewebbn ? The reason I didn't add a flag is, so I have more flexibility in what I write in the input. You can construct the input string based on https://pkg.go.dev/regexp/syntax

That works, I wasn't aware of using "(?i)" to make the search case-insensitive. Might be a tip for your readme.

I already added it. But basically you can build whatever you want with the syntax described in https://pkg.go.dev/regexp/syntax