diff options
Diffstat (limited to 'org/spine.org')
| -rw-r--r-- | org/spine.org | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/org/spine.org b/org/spine.org index 4f2d551..65cb2fe 100644 --- a/org/spine.org +++ b/org/spine.org @@ -394,6 +394,7 @@ NOTES on configuration hierarchy: see meta_conf_make_meta.org #+BEGIN_SRC d string[string] settings = [ "output" : "", + "ssp-round-trip" : "", "www-http" : "", "www-host" : "", "www-host-doc-root" : "", @@ -460,6 +461,7 @@ auto helpInfo = getopt(args, "odf", "open document format text (--odt)", &opts["odf"], "odt", "open document format text", &opts["odt"], "output", "=/path/to/output/dir specify where to place output", &settings["output"], + "ssp-round-trip", "=/path/to/file.ssp read a .ssp back and re-emit it on stdout", &settings["ssp-round-trip"], "parallel", "parallelisation", &opts["parallel"], "parallel-subprocesses", "nested parallelisation", &opts["parallel-subprocesses"], "pdf", "latex output for pdfs", &opts["pdf"], @@ -539,6 +541,49 @@ auto helpInfo = getopt(args, if (helpInfo.helpWanted) { defaultGetoptPrinter("Some information about the program.", helpInfo.options); } +/+ ↓ read a .ssp back into the abstraction and emit it again, on stdout. + the two should be byte identical: that is the check that the reader is + faithful, and it is made against the writer's own record definition, + not against a second description of the format ++/ +if (settings["ssp-round-trip"].length > 0) { + import sisudoc.ocda.abstraction.ssp; + import sisudoc.ocda.abstraction.ssp_in; + mixin spineAbstractionRead; + mixin sspObjectRecord; + auto _doc = sspReadFile(settings["ssp-round-trip"]); + string[] _out; + if (_doc.format.length > 0) { _out ~= _doc.format; } + if (_doc.source.length > 0) { _out ~= "% Source: " ~ _doc.source; } + _out ~= ""; + void _block(string _name, string[] _keys, string[string] _kv) { + _out ~= "@" ~ _name ~ " {"; + foreach (k; _keys) { + if (k in _kv) { _out ~= " " ~ k ~ ": " ~ _kv[k]; } + } + _out ~= "}"; + _out ~= ""; + } + _block("meta", _doc.meta_order, _doc.meta); + _block("make", _doc.make_order, _doc.make); + _block("doc_has", _doc.doc_has_order, _doc.doc_has); + foreach (section; _doc.section_order) { + _out ~= "@" ~ section ~ " {"; + _out ~= ""; + foreach (obj; _doc.abstraction[section]) { + _out ~= sspObjectRecord(obj, section); + } + _out ~= "}"; + _out ~= ""; + } + foreach (line; _out) { writeln(line); } + /+ ↓ the document goes to stdout, so the run-complete banner that + scope(success) prints would be part of it; leave without it + +/ + import core.stdc.stdlib : exit; + stdout.flush; + exit(0); +} #+END_SRC **** getopt hash to struct |
