On Mon, Jul 28, 2014 at 8:13 PM, Nico Williams <n...@cryptonector.com> wrote:
> Sure, a JSON representation of the same data would be more portable in > some sense, but either way you have a standard representation of > ahem... [stephan@host:~/cvs/fossil/cwal/s2]$ f json timeline checkin -n 1 -I 2 { "fossil":"d7d265502a660e1dc5ef41fbe6978f32f507a00e", "timestamp":1406571857, "command":"timeline/checkin", "procTimeUs":5331, "procTimeMs":5, "payload":{ "limit":1, "timeline":[{ "type":"checkin", "uuid":"df7edd343223bfc799a2d84b3029aea6a3cf2e3f", "isLeaf":true, "timestamp":1406562830, "user":"stephan", "comment":"s2sh now prefers getenv(\"S2SH_INIT_SCRIPT\") over $0.s2, but will use the latter if the former is not set.", "parents":["d650f43d56510f086ff2e7159b6b3450e9c0df6f"], "tags":["trunk"] }] } } resp. /json/timeline/checkin?limit=1&indent=2 with the libfossil script bindings, you've got complete db access and conversion from that to JSON is built in to the language: [stephan@host:~/cvs/fossil/libfossil/s2]$ ./s2sh -v verbose: Auto-loading script [./s2sh.s2]. s2 interactive shell. ... s2> var f =Fossil.Context.new(); result: Context@0x904a50[scope=#1@0x7fff77f593c8 ref#=1] ==> Context@0x904a50 s2> f.openCheckout() result: Context@0x904a50[scope=#1@0x7fff77f593c8 ref#=1] ==> Context@0x904a50 s2> f.db.selectObject("select * from event order by mtime DESC limit 1") result: object@0x937d50[scope=#1@0x7fff77f593c8 ref#=0] ==> { "omtime": 2456867.202998, "brief": null, "comment": "s2: minor tweaks to the CGI bits, added Fossil.file.pushd/popd() to s2sh.s2. Fixed (with valgrinds help) stale native pointers to fsl_db instances left around by a missing piece in the Fossil.Context cleanup.", "ecomment": null, "user": "stephan", "euser": null, "bgcolor": null, "uid": null, "tagid": null, "objid": 5919, "mtime": 2456867.202998, "type": "ci" } (lol... that particular commit fixed a nasty bug in that very db binding.) > SQL is declarative, jq is functional. There's a pattern there :) > s2> f.db.each({sql:'select uid, login from user', callback:proc(){1===rowNumber && print(columnNames); print(this)}}) ["uid", "login"] [2, "anonymous"] [9, "apotheon"] [7, "bch"] [4, "developer"] [6, "drh"] [8, "jan.nijtmans"] [3, "nobody"] [5, "reader"] [1, "stephan"] result: Db@0x9273a0[scope=#1@0x7fff77f593c8 ref#=1] ==> Db@0x9273a0 :) -- ----- stephan beal http://wanderinghorse.net/home/stephan/ http://gplus.to/sgbeal "Freedom is sloppy. But since tyranny's the only guaranteed byproduct of those who insist on a perfect world, freedom will have to do." -- Bigby Wolf
_______________________________________________ fossil-users mailing list fossil-users@lists.fossil-scm.org http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users