Add JSON output format and a separate interpreter binary

deck-engine gains --format json (language-independent, slug-based)
so a new dist/interpreter-cli can score how significant a day's
transits are without linking the engine itself — it depends only on
the JSON shape, via its own minimal parser. Also documents the full
reading pipeline end to end (CLAUDE.md, README, docs/) and adds
docs/reading.md, a non-technical explanation of what a daily reading
contains and means.
This commit is contained in:
ml
2026-07-05 15:55:43 +02:00
parent 57deb62b51
commit bd739ccfdf
25 changed files with 1497 additions and 11 deletions
+9 -4
View File
@@ -8,13 +8,13 @@
#include "reading.h"
#include "i18n.h"
typedef enum { FORMAT_TEXT, FORMAT_HTML } OutputFormat;
typedef enum { FORMAT_TEXT, FORMAT_HTML, FORMAT_JSON } OutputFormat;
static void print_usage(const char *prog) {
fprintf(stderr,
"Usage: %s --seed <string> --birth-date YYYY-MM-DD --birth-time HH:MM\n"
" --birth-utc-offset <hours> --birth-lat <deg> --birth-lon <deg>\n"
" [--date YYYY-MM-DDTHH:MM] [--format text|html]\n"
" [--date YYYY-MM-DDTHH:MM] [--format text|html|json]\n"
" [--lang <code>] [--i18n-dir <path>]\n\n"
" --seed Tarot seed string; same seed -> same Celtic Cross spread.\n"
" --birth-date/time Birth date/time in local clock time.\n"
@@ -23,7 +23,9 @@ static void print_usage(const char *prog) {
" --date UTC moment for today's transits/tarot draw. Defaults to now.\n"
" --format Output format, defaults to text. html links card art via\n"
" img/<file>, i.e. it expects to be saved next to the img/\n"
" directory that `make images` copies into dist/.\n"
" directory that `make images` copies into dist/. json uses\n"
" stable, language-independent identifiers (not --lang's\n"
" display text) - it's the interpreter/ module's input format.\n"
" --lang Reading language code, defaults to en. Matches a file\n"
" named <code>.lang in --i18n-dir (see engine/i18n/).\n"
" --i18n-dir Directory to look up <lang>.lang in. Defaults to the\n"
@@ -128,8 +130,9 @@ int main(int argc, char **argv) {
OutputFormat format;
if (strcmp(format_str, "text") == 0) format = FORMAT_TEXT;
else if (strcmp(format_str, "html") == 0) format = FORMAT_HTML;
else if (strcmp(format_str, "json") == 0) format = FORMAT_JSON;
else {
fprintf(stderr, "Invalid --format, expected text or html\n");
fprintf(stderr, "Invalid --format, expected text, html, or json\n");
return 1;
}
@@ -149,6 +152,8 @@ int main(int argc, char **argv) {
if (format == FORMAT_HTML) {
reading_print_html(&reading, stdout);
} else if (format == FORMAT_JSON) {
reading_print_json(&reading, stdout);
} else {
reading_print_text(&reading, stdout);
}