From cafc65aea7f0b3f25ba6b14a34562e1b98ef707d Mon Sep 17 00:00:00 2001 From: "T. von Dein" Date: Wed, 29 Apr 2026 08:33:10 +0200 Subject: [PATCH] fix #24: clarify template use of .Value (#25) --- anydb.1 | 18 ++++++++++++++++-- anydb.pod | 11 +++++++++++ cfg/config.go | 2 +- cmd/anydb.go | 13 ++++++++++++- 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/anydb.1 b/anydb.1 index 5963217..5ba505c 100644 --- a/anydb.1 +++ b/anydb.1 @@ -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 diff --git a/anydb.pod b/anydb.pod index 836585e..4cee91d 100644 --- a/anydb.pod +++ b/anydb.pod @@ -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 diff --git a/cfg/config.go b/cfg/config.go index f860ffe..bbfa6df 100644 --- a/cfg/config.go +++ b/cfg/config.go @@ -30,7 +30,7 @@ import ( "github.com/tlinden/yadu" ) -var Version string = "v0.3.0" +var Version string = "v0.3.1" type BucketConfig struct { Encrypt bool diff --git a/cmd/anydb.go b/cmd/anydb.go index 4911b1e..28414a8 100644 --- a/cmd/anydb.go +++ b/cmd/anydb.go @@ -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: