diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-29 20:04:55 -0400 |
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2026-10-02 21:38:59 -0400 |
| commit | e3410567f75f04ffe42321f9f0b105f793f32cd5 (patch) | |
| tree | 1c4c7bf02660d24c4535425df0f78e01d2e2cbc7 /gleam/src/ocda_lib.gleam | |
| parent | Gleam: what a source holds, and what a database holds unread (diff) | |
Gleam: ocda-read, byte for byte the D reader's
ocda-lib read, installed also as ocda-read: the modes the Gleam readers
had (the summary, --tree/--outline, --languages, --files,
--report-unknown), over the library, in src/read/, which is where
Gleam must put it. A D-only mode asked of it says so.
Its output is the D ocda-read's. For that the D reader's closing hint
no longer lists its modes, which this one has fewer of: both say that
--help lists them.
Checked over the 36 document-languages, on the .ssp and the .ocda.db:
D == Gleam byte for byte in all five modes, 36 of 36. And the same
from the .ssp, the .ocda.db and the .zip (a .sisupod unwrapped, the
Gleam library having no zstd): the summary, --tree and
--report-unknown 36 of 36; --languages of a database == of its pod
27 of 27, and of a single-language .ssp == its database; --files
answers for a database and says why not for the others, in the same
words in both languages.
(assisted by Claude-Code)
Diffstat (limited to 'gleam/src/ocda_lib.gleam')
| -rw-r--r-- | gleam/src/ocda_lib.gleam | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/gleam/src/ocda_lib.gleam b/gleam/src/ocda_lib.gleam index 1e8a5ae..6eccaff 100644 --- a/gleam/src/ocda_lib.gleam +++ b/gleam/src/ocda_lib.gleam @@ -1,10 +1,11 @@ //// ocda-lib, in Gleam: the abstraction as a library, put to the question. //// -//// A library has no binary, so this is the two programs that test its -//// claims. +//// A library has no binary, so this is the programs over it: the reader, +//// and the two that test its claims. //// //// ocda-lib dump [--unknown] <file>.ssp|<file>.ocda.db [lang] //// ocda-lib agree <doc>.ssp <doc>.ocda.db [lang] +//// ocda-lib read [options] <file> [lang] (also installed as ocda-read) //// //// `dump` writes the whole loaded model out canonically, byte for byte as //// the D library's `ocda-dump` writes it, so that the two implementations @@ -20,6 +21,7 @@ import gleam/string import ocda/dump import ocda/load import ocda/model.{type Document} +import read/main as reader pub fn main() { case argv.load().arguments { @@ -29,6 +31,11 @@ pub fn main() { ["dump", path, lang] -> dump_file(path, lang, False) ["agree", ssp, db] -> agree(ssp, db, "") ["agree", ssp, db, lang] -> agree(ssp, db, lang) + ["read", ..rest] -> + case reader.run(rest) { + 0 -> Nil + code -> halt(code) + } _ -> usage() } } @@ -36,7 +43,8 @@ pub fn main() { fn usage() -> Nil { io.println_error( "usage: ocda-lib dump [--unknown] <file>.ssp|<file>.ocda.db [lang] - ocda-lib agree <doc>.ssp <doc>.ocda.db [lang]", + ocda-lib agree <doc>.ssp <doc>.ocda.db [lang] + ocda-lib read [--help] [options] <file> [lang]", ) halt(2) } |
