mirror of
https://codeberg.org/scip/anydb.git
synced 2025-12-16 20:10:59 +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:
6
Makefile
6
Makefile
@@ -103,3 +103,9 @@ lint:
|
||||
lint-full:
|
||||
golangci-lint run --enable-all --exclude-use-default --disable exhaustivestruct,exhaustruct,depguard,interfacer,deadcode,golint,structcheck,scopelint,varcheck,ifshort,maligned,nosnakecase,godot,funlen,gofumpt,cyclop,noctx,gochecknoglobals,paralleltest,forbidigo,gci,godox,goimports,ireturn,stylecheck,testpackage,mirror,nestif,revive,goerr113,gomnd
|
||||
gocritic check -enableAll *.go
|
||||
|
||||
demo:
|
||||
make -C demo demo
|
||||
|
||||
|
||||
.PHONY: demo
|
||||
|
||||
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
|
||||
|
||||
|
||||
26
app/db.go
26
app/db.go
@@ -61,6 +61,24 @@ type DbTag struct {
|
||||
|
||||
const BucketData string = "data"
|
||||
|
||||
func GetDbFile(file string) string {
|
||||
if file != "" {
|
||||
return file
|
||||
}
|
||||
|
||||
file = os.Getenv("ANYDB_DB")
|
||||
if file != "" {
|
||||
return file
|
||||
}
|
||||
|
||||
home, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return filepath.Join(home, ".config", "anydb", "default.db")
|
||||
}
|
||||
|
||||
func New(file string, bucket string, debug bool) (*DB, error) {
|
||||
return &DB{Debug: debug, Dbfile: file, Bucket: bucket}, nil
|
||||
}
|
||||
@@ -131,7 +149,7 @@ func (db *DB) List(attr *DbAttr, fulltext bool) (DbEntries, error) {
|
||||
value := databucket.Get([]byte(entry.Key)) // empty is ok
|
||||
vc := make([]byte, len(value))
|
||||
copy(vc, value)
|
||||
entry.Value = vc
|
||||
entry.Value = string(vc)
|
||||
}
|
||||
|
||||
var include bool
|
||||
@@ -326,7 +344,7 @@ func (db *DB) Get(attr *DbAttr) (*DbEntry, error) {
|
||||
vc := make([]byte, len(value))
|
||||
copy(vc, value)
|
||||
|
||||
entry.Value = vc
|
||||
entry.Value = string(vc)
|
||||
|
||||
return nil
|
||||
})
|
||||
@@ -422,7 +440,7 @@ func (db *DB) Import(attr *DbAttr) (string, error) {
|
||||
}
|
||||
|
||||
// write value
|
||||
err = databucket.Put([]byte(entry.Key), entry.Value)
|
||||
err = databucket.Put([]byte(entry.Key), []byte(entry.Value))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to insert data: %w", err)
|
||||
}
|
||||
@@ -525,7 +543,7 @@ func (db *DB) Getall(attr *DbAttr) (DbEntries, error) {
|
||||
vc := make([]byte, len(value))
|
||||
copy(vc, value)
|
||||
|
||||
entry.Value = vc
|
||||
entry.Value = string(vc)
|
||||
entries = append(entries, &entry)
|
||||
|
||||
return nil
|
||||
|
||||
@@ -33,7 +33,7 @@ type DbEntry struct {
|
||||
Size uint64 `protobuf:"varint,6,opt,name=Size,proto3" json:"Size,omitempty"`
|
||||
Encrypted bool `protobuf:"varint,7,opt,name=Encrypted,proto3" json:"Encrypted,omitempty"`
|
||||
Binary bool `protobuf:"varint,8,opt,name=Binary,proto3" json:"Binary,omitempty"`
|
||||
Value []byte `protobuf:"bytes,9,opt,name=Value,proto3" json:"Value,omitempty"`
|
||||
Value string `protobuf:"bytes,9,opt,name=Value,proto3" json:"Value,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@@ -124,11 +124,11 @@ func (x *DbEntry) GetBinary() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *DbEntry) GetValue() []byte {
|
||||
func (x *DbEntry) GetValue() string {
|
||||
if x != nil {
|
||||
return x.Value
|
||||
}
|
||||
return nil
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_app_dbentry_proto protoreflect.FileDescriptor
|
||||
@@ -152,7 +152,7 @@ var file_app_dbentry_proto_rawDesc = []byte{
|
||||
0x28, 0x08, 0x52, 0x09, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, 0x12, 0x16, 0x0a,
|
||||
0x06, 0x42, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x42,
|
||||
0x69, 0x6e, 0x61, 0x72, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x09,
|
||||
0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x1e, 0x5a, 0x1c, 0x67,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x1e, 0x5a, 0x1c, 0x67,
|
||||
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x6c, 0x69, 0x6e, 0x64, 0x65,
|
||||
0x6e, 0x2f, 0x61, 0x6e, 0x79, 0x64, 0x62, 0x2f, 0x61, 0x70, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x33,
|
||||
|
||||
@@ -16,5 +16,5 @@ message DbEntry {
|
||||
uint64 Size = 6;
|
||||
bool Encrypted = 7;
|
||||
bool Binary = 8;
|
||||
bytes Value = 9;
|
||||
string Value = 9;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
"github.com/tlinden/anydb/common"
|
||||
)
|
||||
|
||||
var Version string = "v0.1.1"
|
||||
var Version string = "v0.1.3"
|
||||
|
||||
type BucketConfig struct {
|
||||
Encrypt bool
|
||||
|
||||
@@ -118,12 +118,12 @@ func Get(conf *cfg.Config) *cobra.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
clear, err := app.Decrypt(pass, entry.Value)
|
||||
clear, err := app.Decrypt(pass, []byte(entry.Value))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
entry.Value = clear
|
||||
entry.Value = string(clear)
|
||||
entry.Encrypted = false
|
||||
}
|
||||
|
||||
|
||||
@@ -216,12 +216,12 @@ func Edit(conf *cfg.Config) *cobra.Command {
|
||||
}
|
||||
password = pass
|
||||
|
||||
clear, err := app.Decrypt(pass, entry.Value)
|
||||
clear, err := app.Decrypt(pass, []byte(entry.Value))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
entry.Value = clear
|
||||
entry.Value = string(clear)
|
||||
entry.Encrypted = false
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,9 @@ func Execute() {
|
||||
Short: "anydb",
|
||||
Long: `A personal key value store`,
|
||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
db, err := app.New(conf.Dbfile, conf.Dbbucket, conf.Debug)
|
||||
dbfile := app.GetDbFile(conf.Dbfile)
|
||||
|
||||
db, err := app.New(dbfile, conf.Dbbucket, conf.Debug)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -114,7 +116,7 @@ func Execute() {
|
||||
rootCmd.PersistentFlags().BoolVarP(&ShowVersion, "version", "v", false, "Print program version")
|
||||
rootCmd.PersistentFlags().BoolVarP(&conf.Debug, "debug", "d", false, "Enable debugging")
|
||||
rootCmd.PersistentFlags().StringVarP(&conf.Dbfile, "dbfile", "f",
|
||||
filepath.Join(home, ".config", "anydb", "default.db"), "DB file to use")
|
||||
"", "DB file to use (default: ~/.config/anydb/default.db)")
|
||||
rootCmd.PersistentFlags().StringVarP(&conf.Dbbucket, "bucket", "b",
|
||||
app.BucketData, "use other bucket (default: "+app.BucketData+")")
|
||||
rootCmd.PersistentFlags().StringVarP(&configfile, "config", "c", "", "toml config file")
|
||||
|
||||
21
demo/Makefile
Normal file
21
demo/Makefile
Normal file
@@ -0,0 +1,21 @@
|
||||
.PHONY: demo clean check clean-demo
|
||||
|
||||
VHS = vhs
|
||||
|
||||
|
||||
|
||||
clean-demo:
|
||||
rm -f local.db*
|
||||
|
||||
%.gif: %.tape
|
||||
@echo "vhs $<"
|
||||
env PATH=..:$(PATH) ANYDB_DB=local.db vhs $<
|
||||
|
||||
clean:
|
||||
rm -vf *.db* *.json
|
||||
|
||||
check:
|
||||
ls -l ../anydb
|
||||
|
||||
demo: check clean-demo intro.gif advanced.gif
|
||||
|
||||
BIN
demo/advanced.gif
Normal file
BIN
demo/advanced.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.9 MiB |
181
demo/advanced.tape
Normal file
181
demo/advanced.tape
Normal file
@@ -0,0 +1,181 @@
|
||||
# -*-sh-*-
|
||||
|
||||
Output advanced.gif
|
||||
Set FontSize 20
|
||||
Set Width 1000
|
||||
Set Height 800
|
||||
Set Theme { "name": "Whimsy", "black": "#535178", "red": "#ef6487", "green": "#5eca89", "yellow": "#fdd877", "blue": "#65aef7", "magenta": "#aa7ff0", "cyan": "#43c1be", "white": "#ffffff", "brightBlack": "#535178", "brightRed": "#ef6487", "brightGreen": "#5eca89", "brightYellow": "#fdd877", "brightBlue": "#65aef7", "brightMagenta": "#aa7ff0", "brightCyan": "#43c1be", "brightWhite": "#ffffff", "background": "#29283b", "foreground": "#b3b0d6", "selection": "#3d3c58", "cursor": "#b3b0d6" }
|
||||
Set WindowBar Colorful
|
||||
Set BorderRadius 10
|
||||
Set Shell zsh
|
||||
Set FontFamily "IBM Plex Mono"
|
||||
Set CursorBlink false
|
||||
Set PlaybackSpeed 1
|
||||
Set TypingSpeed .05
|
||||
|
||||
Hide
|
||||
Type `PROMPT=''`
|
||||
Enter
|
||||
Type "setopt interactivecomments"
|
||||
Enter
|
||||
Type "autoload -U colors && colors"
|
||||
Enter
|
||||
Type `PS1="%{$fg[magenta]%}demo> %{$reset_color%}"`
|
||||
Enter
|
||||
Type "clear"
|
||||
Enter
|
||||
Show
|
||||
|
||||
|
||||
Type "# you can assign tags"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "anydb set foo bar -t note,important"
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
Enter
|
||||
Type "# and filter for them"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "anydb list -t important"
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
Enter
|
||||
Type "# beside tags filtering you can also use regexps for searching"
|
||||
Enter
|
||||
Type "# note, by default the list command only searches through keys"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "anydb list '[a-z]+'"
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
Enter
|
||||
Type "# do a full text search"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "anydb list '[a-z]+' -s"
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
Enter
|
||||
Type "# anydb also supports a wide output"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "anydb list -m wide"
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
Enter
|
||||
Type "# there are shortcuts as well"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "anydb ls -l"
|
||||
Enter
|
||||
Sleep 2s
|
||||
Type "anydb /"
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
Enter
|
||||
Type "# other outputs are possible as well"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "anydb list -m json"
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
Enter
|
||||
Type "# you can backup your database"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "anydb export -o backup.json"
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
Enter
|
||||
Type "# and import it somewhere else"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "rm local.db"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "anydb ls -l"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "anydb import -i backup.json"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "anydb ls -l"
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
Enter
|
||||
Type "# you can encrypt entries. anydb asks for a passphrase"
|
||||
Enter
|
||||
Type "# and will do the same when you retrieve the key using the"
|
||||
Enter
|
||||
Type "# get command. anydb will ask you interactively for a password"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "anydb set address 'Beatstreet 42' -e"
|
||||
Enter
|
||||
Type "pass"
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
Enter
|
||||
Type "# but you can provide it via an environment variable too"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "ANYDB_PASSWORD=foo anydb set -e secretkey blahblah"
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
Enter
|
||||
Type "# using template output mode you can freely design how to print stuff"
|
||||
Enter
|
||||
Type "# here, we print the values in CSV format ONLY if they have some tag"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type `anydb ls -m template -T "{{ if .Tags }}{{ .Key }},{{ .Value }},{{ .Created}}{{ end }}"`
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
Enter
|
||||
Type "# or, to simulate skate's -k or -v"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type `anydb ls -m template -T "{{ .Key }}"`
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type `anydb ls -m template -T "{{ .Value }}"`
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
Enter
|
||||
Type "# maybe you want to digest the item in a shell script? also"
|
||||
Enter
|
||||
Type "# note, that both the list and get commands support templates"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type `eval $(anydb get kitty -m template -T "value='{{ .Value }}'"); echo "value: $value"`
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
Enter
|
||||
Type "# sometimes you need to know some details about the current database"
|
||||
Enter
|
||||
Type "# add -d for more details"
|
||||
Enter
|
||||
Sleep 1
|
||||
Type "anydb info"
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
Enter
|
||||
Type "# Try it out yourself: github.com/tlinden/anydb!"
|
||||
Enter
|
||||
Sleep 4s
|
||||
BIN
demo/intro.gif
Normal file
BIN
demo/intro.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 260 KiB |
76
demo/intro.tape
Normal file
76
demo/intro.tape
Normal file
@@ -0,0 +1,76 @@
|
||||
# -*-sh-*-
|
||||
|
||||
Output intro.gif
|
||||
Set FontSize 20
|
||||
Set Width 1000
|
||||
Set Height 800
|
||||
Set Theme { "name": "Whimsy", "black": "#535178", "red": "#ef6487", "green": "#5eca89", "yellow": "#fdd877", "blue": "#65aef7", "magenta": "#aa7ff0", "cyan": "#43c1be", "white": "#ffffff", "brightBlack": "#535178", "brightRed": "#ef6487", "brightGreen": "#5eca89", "brightYellow": "#fdd877", "brightBlue": "#65aef7", "brightMagenta": "#aa7ff0", "brightCyan": "#43c1be", "brightWhite": "#ffffff", "background": "#29283b", "foreground": "#b3b0d6", "selection": "#3d3c58", "cursor": "#b3b0d6" }
|
||||
Set WindowBar Colorful
|
||||
Set BorderRadius 10
|
||||
Set Shell zsh
|
||||
Set FontFamily "IBM Plex Mono"
|
||||
Set CursorBlink false
|
||||
Set PlaybackSpeed 1
|
||||
Set TypingSpeed .05
|
||||
|
||||
Hide
|
||||
Type `PROMPT=''`
|
||||
Enter
|
||||
Type "setopt interactivecomments"
|
||||
Enter
|
||||
Type "autoload -U colors && colors"
|
||||
Enter
|
||||
Type `PS1="%{$fg[magenta]%}demo> %{$reset_color%}"`
|
||||
Enter
|
||||
Type "clear"
|
||||
Enter
|
||||
Show
|
||||
|
||||
Type "# Store something"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "anydb set kitty meow"
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
Enter
|
||||
Type `# What's in the store?`
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "anydb ls"
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
Enter
|
||||
Type "# Fetch something"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "anydb get kitty"
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
Enter
|
||||
Type "# Unicode also works, of course"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "anydb set 猫咪 喵"
|
||||
Enter
|
||||
Sleep 2s
|
||||
Type "anydb get 猫咪"
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
Enter
|
||||
Type "# Do creative things with anydb list"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "anydb set penelope marmalade"
|
||||
Enter
|
||||
Type "anydb set christian tacos"
|
||||
Enter
|
||||
Type "anydb set muesli muesli"
|
||||
Enter
|
||||
Type "anydb list | xargs -n 2 printf '%s loves %s.\n'"
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
39
go.mod
39
go.mod
@@ -3,31 +3,34 @@ module github.com/tlinden/anydb
|
||||
go 1.22.1
|
||||
|
||||
require (
|
||||
github.com/alecthomas/repr v0.4.0 // indirect
|
||||
github.com/andybalholm/brotli v1.1.0 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/gofiber/fiber/v2 v2.52.5 // indirect
|
||||
github.com/alecthomas/repr v0.4.0
|
||||
github.com/dustin/go-humanize v1.0.1
|
||||
github.com/gofiber/fiber/v2 v2.52.6
|
||||
github.com/inconshreveable/mousetrap v1.1.0
|
||||
github.com/olekukonko/tablewriter v0.0.5
|
||||
github.com/pelletier/go-toml v1.9.5
|
||||
github.com/rogpeppe/go-internal v1.13.1
|
||||
github.com/spf13/cobra v1.8.1
|
||||
go.etcd.io/bbolt v1.3.11
|
||||
golang.org/x/crypto v0.31.0
|
||||
golang.org/x/term v0.27.0
|
||||
google.golang.org/protobuf v1.36.4
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/andybalholm/brotli v1.1.1 // indirect
|
||||
github.com/gofiber/fiber/v3 v3.0.0-beta.3 // indirect
|
||||
github.com/gofiber/utils/v2 v2.0.0-beta.4 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/klauspost/compress v1.17.9 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/klauspost/compress v1.17.11 // indirect
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.15 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/pelletier/go-toml v1.9.5 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.16 // indirect
|
||||
github.com/rivo/uniseg v0.2.0 // indirect
|
||||
github.com/rogpeppe/go-internal v1.13.1 // indirect
|
||||
github.com/spf13/cobra v1.8.1 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/spf13/pflag v1.0.6 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasthttp v1.55.0 // indirect
|
||||
github.com/valyala/tcplisten v1.0.0 // indirect
|
||||
go.etcd.io/bbolt v1.3.11 // indirect
|
||||
golang.org/x/crypto v0.31.0 // indirect
|
||||
golang.org/x/sys v0.28.0 // indirect
|
||||
golang.org/x/term v0.27.0 // indirect
|
||||
golang.org/x/sys v0.29.0 // indirect
|
||||
golang.org/x/tools v0.22.0 // indirect
|
||||
google.golang.org/protobuf v1.36.1 // indirect
|
||||
)
|
||||
|
||||
17
go.sum
17
go.sum
@@ -6,6 +6,8 @@ github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/
|
||||
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
|
||||
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
|
||||
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
|
||||
github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA=
|
||||
github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA=
|
||||
github.com/asdine/storm/v3 v3.2.1 h1:I5AqhkPK6nBZ/qJXySdI7ot5BlXSZ7qvDY1zAn5ZJac=
|
||||
github.com/asdine/storm/v3 v3.2.1/go.mod h1:LEpXwGt4pIqrE/XcTvCnZHT5MgZCV6Ub9q7yQzOFWr0=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
@@ -14,6 +16,8 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/gofiber/fiber/v2 v2.52.5 h1:tWoP1MJQjGEe4GB5TUGOi7P2E0ZMMRx5ZTG4rT+yGMo=
|
||||
github.com/gofiber/fiber/v2 v2.52.5/go.mod h1:KEOE+cXMhXG0zHc9d8+E38hoX+ZN7bhOtgeF2oT6jrQ=
|
||||
github.com/gofiber/fiber/v2 v2.52.6 h1:Rfp+ILPiYSvvVuIPvxrBns+HJp8qGLDnLJawAu27XVI=
|
||||
github.com/gofiber/fiber/v2 v2.52.6/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw=
|
||||
github.com/gofiber/fiber/v3 v3.0.0-beta.3 h1:7Q2I+HsIqnIEEDB+9oe7Gadpakh6ZLhXpTYz/L20vrg=
|
||||
github.com/gofiber/fiber/v3 v3.0.0-beta.3/go.mod h1:kcMur0Dxqk91R7p4vxEpJfDWZ9u5IfvrtQc8Bvv/JmY=
|
||||
github.com/gofiber/utils/v2 v2.0.0-beta.4 h1:1gjbVFFwVwUb9arPcqiB6iEjHBwo7cHsyS41NeIW3co=
|
||||
@@ -31,11 +35,15 @@ github.com/klauspost/compress v1.17.0 h1:Rnbp4K9EjcDuVuHtd0dgA4qNuv9yKDYKK1ulpJw
|
||||
github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
|
||||
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
|
||||
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
||||
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
|
||||
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
@@ -43,6 +51,8 @@ github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/Qd
|
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
|
||||
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
||||
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
||||
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
|
||||
@@ -57,6 +67,8 @@ github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
|
||||
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
|
||||
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
@@ -67,6 +79,7 @@ github.com/valyala/fasthttp v1.55.0/go.mod h1:NkY9JtkrpPKmgwV3HTaS2HWaJss9RSIsRV
|
||||
github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8=
|
||||
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
|
||||
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
|
||||
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
|
||||
go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
|
||||
go.etcd.io/bbolt v1.3.11 h1:yGEzV1wPz2yVCLsD8ZAiGHhHVlczyC9d1rP43/VCRJ0=
|
||||
go.etcd.io/bbolt v1.3.11/go.mod h1:dksAq7YMXoljX0xu6VF5DMZGbhYYoLUalEiSySYAS4I=
|
||||
@@ -81,6 +94,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
|
||||
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
|
||||
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
|
||||
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
@@ -91,6 +106,8 @@ golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c
|
||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk=
|
||||
google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM=
|
||||
google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
@@ -43,7 +43,7 @@ func Print(writer io.Writer, conf *cfg.Config, attr *app.DbAttr, entry *app.DbEn
|
||||
if isatty {
|
||||
fmt.Println("binary data omitted")
|
||||
} else {
|
||||
os.Stdout.Write(entry.Value)
|
||||
os.Stdout.WriteString(entry.Value)
|
||||
}
|
||||
} else {
|
||||
fmt.Print(string(entry.Value))
|
||||
@@ -85,7 +85,7 @@ func WriteFile(writer io.Writer, conf *cfg.Config, attr *app.DbAttr, entry *app.
|
||||
}
|
||||
|
||||
// actually write file content
|
||||
_, err = fileHandle.Write(entry.Value)
|
||||
_, err = fileHandle.WriteString(entry.Value)
|
||||
|
||||
if !entry.Binary {
|
||||
if entry.Value[entry.Size-1] != '\n' {
|
||||
|
||||
Reference in New Issue
Block a user