ZettelGeist / zettelgeist

A less-is-more (distributed) notetaking application. Designed specifically for those who prefer working with the command line and want to do crazy indexing, analysis, and transformation of notes. Aimed at but not limited to scholarly research projects.
Apache License 2.0
30 stars 5 forks source link

use YAML not JSON for .counter.dat #37

Open icornelius opened 2 years ago

icornelius commented 2 years ago

The --counter option assigns a serial number to new notes created with the zettel command. Usage:

--counter COUNTER     counter name (defaults to --id if present)

The file .counter.dat maintains the count of zetteln written for each COUNTER. This is serialized in JSON.

I suggest switching to YAML since that will introduce newlines in the file and simplify resolution of git merge conflicts in distributed projects. Alternatively, users could add .counter.dat to their .gitignore. Then each local system would keep its own separate count, defeating the purpose of a counter.

icornelius commented 11 months ago

The relevant commit, setting counter output, is d39210b39b49da6c4d8512b1312da1441fe423e6. See also 02de204aa5dd760d2385a1554c48853f4e3356e4.

A final newline should be written to the end of .counter.dat, to facilitate display in the terminal (e.g., with cat).

icornelius commented 5 months ago

19895713194dfa849d36941513e7b9d5720a6b3c is sufficient because yaml.load reads any existing json-encoded .counter.dat on first invocation. There is no need for a dedicated one-time translation between formats, as yaml is a superset of json.