←back to thread

115 points graderjs | 2 comments | | HN request time: 0.432s | source
Show context
andreareina ◴[] No.25005050[source]
Could use an example of the database file and diffs.

I have vague recollections of a tool that was similarly supposed to make JSON files diffable. IIRC it procedurally built up the object, so {"foo": {"bar": "baz", "quux": [1, 2, 3]}} would be:

    foo = {}
    foo.bar = "baz"
    foo.baz = []
    foo.baz[0] = 1
    ...
replies(3): >>25005118 #>>25005451 #>>25005522 #
emmelaich ◴[] No.25005522[source]
Augtool from the Augeas project too. (As well as the mentioned gron)
replies(1): >>25005552 #
emmelaich ◴[] No.25005552[source]
example

   $ augtool -r . --noautoload --transform "Json.lns incl /sirdb-example.json" <<EOF
   > print /files/sirdb-example.json/
   > EOF
   /files/sirdb-example.json
   /files/sirdb-example.json/dict
   /files/sirdb-example.json/dict/entry[1] = "_owner"
   /files/sirdb-example.json/dict/entry[1]/string = "nouser"
   /files/sirdb-example.json/dict/entry[2] = "username"
   /files/sirdb-example.json/dict/entry[2]/string = "nouser"
   /files/sirdb-example.json/dict/entry[3] = "email"
   .... etc ...
replies(1): >>25008411 #
1. chousuke ◴[] No.25008411[source]
I find it unfortunate that augeas is so magical. Or rather, the design of its interface is very surprising

What's up with requiring "--noautoload"? What does "-r ." do? and the transform invocation starts with the seemingly magical "Json.lns" (where does it come from?) and appears to refer to a file at the root of the filesystem hierarchy?

I'd probably use augtool more often myself, but its UI is seriously inscrutable.

replies(1): >>25012012 #
2. emmelaich ◴[] No.25012012[source]
I agree, fwiw.

I'm writing a little program to make this whole lot easier.

Answers: by default, augtool loads all the lenses and scans the entire default filesystem (typically /etc); `--noautoload` prevents that.

The -r is `--root`; specify the root as the current directory rather than /