3 Commits

7 changed files with 58 additions and 6 deletions

View File

@@ -6,7 +6,7 @@ variables:
steps:
dryrun:
image: docker.io/woodpeckerci/plugin-docker-buildx:latest
image: docker.io/woodpeckerci/plugin-docker-buildx:6.0.3
settings:
dockerfile: Dockerfile
platforms: linux/amd64
@@ -17,7 +17,7 @@ steps:
event: [pull_request]
publish:
image: docker.io/woodpeckerci/plugin-docker-buildx:latest
image: docker.io/woodpeckerci/plugin-docker-buildx:6.0.3
settings:
dockerfile: Dockerfile
platforms: linux/amd64

18
anydb.1
View File

@@ -133,7 +133,7 @@
.\" ========================================================================
.\"
.IX Title "ANYDB 1"
.TH ANYDB 1 "2025-11-03" "1" "User Commands"
.TH ANYDB 1 "2026-04-29" "1" "User Commands"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
@@ -613,8 +613,16 @@ The following template variables can be used:
.PD 0
.IP "\fB.Value\fR \- string" 4
.IX Item ".Value - string"
.PD
To be able to use the value in a template, you'll need to add the
\&\f(CW\*(C`\-s\*(C'\fR flag so that values are included in output data
stream. Otherwise you can only use \f(CW\*(C`.Preview\*(C'\fR.
.IP "\fB.Preview\fR string" 4
.IX Item ".Preview string"
First line of entry value (if it is a string).
.IP "\fB.Bin\fR \- []byte" 4
.IX Item ".Bin - []byte"
.PD 0
.IP "\fB.Created\fR \- timestamp.Time" 4
.IX Item ".Created - timestamp.Time"
.PD
@@ -729,7 +737,7 @@ Some curl example calls to the \s-1API:\s0
Post a new key:
curl \-X \s-1PUT\s0 localhost:8787/anydb/v1/ \e
\-H 'Content\-Type: application/json' \e
\-d '{\*(L"key\*(R":\*(L"foo\*(R",\*(L"val\*(R":\*(L"bar\*(R"}'
\-d '{\*(L"key\*(R":\*(L"foo\*(R",\*(L"data\*(R":\*(L"bar\*(R"}'
.PP
Retrieve the value:
.PP
@@ -742,6 +750,12 @@ List all keys:
.Vb 1
\& curl localhost:8787/anydb/v1/
.Ve
.PP
Delete an entry:
.PP
.Vb 1
\& curl \-s \-X DELETE http://localhost:8787/anydb/v1/foo
.Ve
.SH "BUGS"
.IX Header "BUGS"
In order to report a bug, unexpected behavior, feature requests

View File

@@ -452,6 +452,17 @@ The following template variables can be used:
=item B<.Value> - string
To be able to use the value in a template, you'll need to add the
C<-s> flag so that values are included in output data
stream. Otherwise you can only use C<.Preview>.
Be careful if you use C<-s> and C<.Value> though: if a value is a
multiline string, it may clutter your output.
=item B<.Preview> string
First line of entry value (if it is a string).
=item B<.Bin> - []byte
=item B<.Created> - timestamp.Time

View File

@@ -91,6 +91,14 @@ func New(file string, bucket string, debug bool) (*DB, error) {
return &DB{Debug: debug, Dbfile: file, Bucket: bucket}, nil
}
func (db *DB) Exists() error {
if !common.FileExists(db.Dbfile) {
return fmt.Errorf("db file %s doesn't exist", db.Dbfile)
}
return nil
}
func (db *DB) Open() error {
slog.Debug("opening DB", "dbfile", db.Dbfile)

View File

@@ -30,7 +30,7 @@ import (
"github.com/tlinden/yadu"
)
var Version string = "v0.3.0"
var Version string = "v0.3.2"
type BucketConfig struct {
Encrypt bool

View File

@@ -413,6 +413,13 @@ TEMPLATES
.Key - string
.Value - string
To be able to use the value in a template, you'll need to add the
"-s" flag so that values are included in output data stream.
Otherwise you can only use ".Preview".
.Preview string
First line of entry value (if it is a string).
.Bin - []byte
.Created - timestamp.Time
To retrieve a string representation of the timestamp, use
@@ -504,7 +511,7 @@ REST API
Some curl example calls to the API:
Post a new key: curl -X PUT localhost:8787/anydb/v1/ \ -H 'Content-Type:
application/json' \ -d '{"key":"foo","val":"bar"}'
application/json' \ -d '{"key":"foo","data":"bar"}'
Retrieve the value:
@@ -514,6 +521,10 @@ REST API
curl localhost:8787/anydb/v1/
Delete an entry:
curl -s -X DELETE http://localhost:8787/anydb/v1/foo
BUGS
In order to report a bug, unexpected behavior, feature requests or to
submit a patch, please open an issue on github:

View File

@@ -107,6 +107,10 @@ func Get(conf *cfg.Config) *cobra.Command {
attr.Key = args[0]
}
if err := conf.DB.Exists(); err != nil {
return err
}
entry, err := conf.DB.Get(&attr)
if err != nil {
return err
@@ -207,6 +211,10 @@ func List(conf *cfg.Config) *cobra.Command {
conf.Mode = "wide"
}
if err := conf.DB.Exists(); err != nil {
return err
}
entries, err := conf.DB.List(&attr, conf.Fulltext)
if err != nil {
return err