mirror of
https://codeberg.org/scip/anydb.git
synced 2025-12-18 04:51:00 +01:00
Feature/vhs demo (#15)
* add vhs made demo gif * add support for ANYDB_DB env var * left one section * fixed data type bug, added demo gifs, upgraded dependencies --------- Co-authored-by: Thomas von Dein <tom@vondein.org>
This commit is contained in:
139
README.md
139
README.md
@@ -34,146 +34,11 @@ And I wrote a very similar [tool](https://www.daemon.de/projects/dbtool/) 24 yea
|
||||
|
||||
**anydb** can do all the things you can do with skate:
|
||||
|
||||
```shell
|
||||
# Store something (and sync it to the network)
|
||||
anydb set kitty meow
|
||||

|
||||
|
||||
# Fetch something (from the local cache)
|
||||
anydb get kitty
|
||||
|
||||
# What’s in the store?
|
||||
anydb list
|
||||
|
||||
# Spaces are fine
|
||||
anydb set "kitty litter" "smells great"
|
||||
|
||||
# You can store binary data, too
|
||||
anydb set profile-pic < my-cute-pic.jpg
|
||||
anydb get profile-pic > here-it-is.jpg
|
||||
|
||||
# Unicode also works, of course
|
||||
anydb set 猫咪 喵
|
||||
anydb get 猫咪
|
||||
|
||||
# For more info
|
||||
anydb --help
|
||||
|
||||
# Do creative things with anydb list
|
||||
anydb set penelope marmalade
|
||||
anydb set christian tacos
|
||||
anydb set muesli muesli
|
||||
|
||||
anydb list | xargs -n 2 printf '%s loves %s.\n'
|
||||
```
|
||||
|
||||
However, there are more features than just that!
|
||||
|
||||
```shell
|
||||
# you can assign tags
|
||||
anydb set foo bar -t note,important
|
||||
|
||||
# and filter for them
|
||||
anydb list -t important
|
||||
|
||||
# beside tags filtering you can also use regexps for searching
|
||||
# note, by default the list command only searches through keys
|
||||
anydb list '[a-z]+\d'
|
||||
|
||||
# do a full text search
|
||||
anydb list '[a-z]+\d' -s
|
||||
|
||||
# anydb also supports a wide output
|
||||
anydb list -m wide
|
||||
KEY TAGS SIZE AGE VALUE
|
||||
blah important 4 B 7 seconds ago haha
|
||||
foo 3 B 15 seconds ago bar
|
||||
猫咪 3 B 3 seconds ago 喵
|
||||
|
||||
# there are shortcuts as well
|
||||
anydb ls -l
|
||||
anydb /
|
||||
|
||||
# other outputs are possible as well
|
||||
anydb list -m json
|
||||
|
||||
# you can backup your database
|
||||
anydb export -o backup.json
|
||||
|
||||
# and import it somewhere else
|
||||
anydb import -i backup.json
|
||||
|
||||
# you can encrypt entries. anydb asks for a passphrase
|
||||
# and will do the same when you retrieve the key using the
|
||||
# get command. anydb will ask you interactively for a password
|
||||
anydb set mypassword -e
|
||||
|
||||
# but you can provide it via an environment variable too
|
||||
ANYDB_PASSWORD=foo anydb set -e secretkey blahblah
|
||||
|
||||
# too tiresome to add -e every time you add an entry?
|
||||
# use a per bucket config
|
||||
cat ~/.config/anydb/anydb.toml
|
||||
[buckets.data]
|
||||
encrypt = true
|
||||
anydb set foo bar # will be encrypted
|
||||
|
||||
# speaking of buckets, you can use different buckets
|
||||
anydb -b test set foo bar
|
||||
|
||||
# and speaking of configs, you can place a config file at these places:
|
||||
# ~/.config/anydb/anydb.toml
|
||||
# ~/.anydb.toml
|
||||
# anydb.toml (current directory)
|
||||
# or specify one using -c <filename>
|
||||
# look at example.toml
|
||||
|
||||
# using template output mode you can freely design how to print stuff
|
||||
# here, we print the values in CSV format ONLY if they have some tag
|
||||
anydb ls -m template -T "{{ if .Tags }}{{ .Key }},{{ .Value }},{{ .Created}}{{ end }}"
|
||||
|
||||
# or, to simulate skate's -k or -v
|
||||
anydb ls -m template -T "{{ .Key }}"
|
||||
anydb ls -m template -T "{{ .Value }}"
|
||||
|
||||
# maybe you want to digest the item in a shell script? also
|
||||
# note, that both the list and get commands support templates
|
||||
eval $(anydb get foo -m template -T "key='{{ .Key }}' value='{{ .Value }}' ts='{{ .Created}}'")
|
||||
echo "$key: $value"
|
||||
|
||||
# run the restful api server
|
||||
anydb serve
|
||||
|
||||
# post a new key
|
||||
curl -X PUT localhost:8787/anydb/v1/ \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"key":"foo","val":"bar"}'
|
||||
|
||||
# retrieve it
|
||||
curl localhost:8787/anydb/v1/foo
|
||||
|
||||
# list keys
|
||||
curl localhost:8787/anydb/v1/
|
||||
|
||||
# same, but do a full text search by content, searching for "foo"
|
||||
curl -X POST http://127.0.0.1:8787/anydb/v1/ \
|
||||
-H 'Content-Type: application/json'
|
||||
-d '{"key":"foo", "fulltext": true}'
|
||||
|
||||
# as you might correctly suspect you can store multi-line values or
|
||||
# the content of text files. but what to do if you want to change it?
|
||||
# here's one way:
|
||||
anydb get contract24 > file.txt && vi file.txt && anydb set contract24 -r file.txt
|
||||
|
||||
# annoying. better do this
|
||||
anydb edit contract24
|
||||
|
||||
# sometimes you need to know some details about the current database
|
||||
# add -d for more details
|
||||
anydb info
|
||||
|
||||
# it comes with a manpage builtin
|
||||
anydb man
|
||||
```
|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user