diff --git a/anydb.pod b/anydb.pod index 5368701..6da0378 100644 --- a/anydb.pod +++ b/anydb.pod @@ -448,17 +448,20 @@ The following template variables can be used: =over -=item B - string +=item B<.Key> - string -=item B - string +=item B<.Value> - string -=item B - []byte +=item B<.Bin> - []byte -=item B - time.Time +=item B<.Created> - timestamp.Time -=item B - []string +To retrieve a string representation of the timestamp, use C<.Created.AsTime>. +If you need a unix timestamp since epoch, use C<.Created.Unix>. -=item B bool +=item B<.Tags> - []string + +=item B<.Encrypted> bool =back @@ -473,12 +476,12 @@ Only show the keys of all entries: Format the list in a way so that is possible to evaluate it in a shell: - eval $(anydb get foo -m template -T "key='{{ .Key }}' value='{{ .Value }}' ts='{{ .Created}}'") - echo "Key: $key, Value: $value" + eval $(anydb get foo -m template -T "key='{{ .Key }}' value='{{ .Value }}' ts='{{ .Created.AsTime}}'") + echo "Key: $key, Value: $value, When: $ts" Print the values in CSV format ONLY if they have some tag: - anydb list -m template -T "{{ if .Tags }}{{ .Key }},{{ .Value }},{{ .Created}}{{ end }}" + anydb list -m template -T "{{ if .Tags }}{{ .Key }},{{ .Value }},{{ .Created.AsTime}}{{ end }}" =head1 CONFIGURATION diff --git a/cfg/config.go b/cfg/config.go index 5a082af..dc99502 100644 --- a/cfg/config.go +++ b/cfg/config.go @@ -26,7 +26,7 @@ import ( "github.com/tlinden/anydb/common" ) -var Version string = "v0.1.3" +var Version string = "v0.1.4" type BucketConfig struct { Encrypt bool diff --git a/demo/advanced.tape b/demo/advanced.tape index ae10ae6..9cb631e 100644 --- a/demo/advanced.tape +++ b/demo/advanced.tape @@ -139,8 +139,9 @@ 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 +Type "# also note, that we're printing the creation timestamp as epoch" Sleep 1s -Type `anydb ls -m template -T "{{ if .Tags }}{{ .Key }},{{ .Value }},{{ .Created}}{{ end }}"` +Type `anydb ls -m template -T "{{ if .Tags }}{{ .Key }},{{ .Value }},{{ .Created.AsTime.Unix}}{{ end }}"` Enter Sleep 3s