import std.path; gendoc.config.Config cfg; ModuleManager modmgr; modmgr.addSources("root", "v1.2.3", __FILE_FULL_PATH__.buildNormalizedPath("../.."), [__FILE__], null); auto pipe = CommandPipe(cfg, modmgr.dubPackages); pipe.run("echo xxx"); pipe.run(["rdmd", "--eval", q{ stderr.writeln(`test1`); stderr.writeln(`::gendoc-request::{ "type": "ReqEcho", "value": {"msg": "test-echo"} }`); stderr.writeln(`test2`); auto res = stdin.readln(); writeln(parseJSON(res)["value"]["msg"].str); stderr.writeln(`::gendoc-request::{ "type": "XXXXX", "value": {"msg": "test"} }`); res = stdin.readln(); writeln(parseJSON(res)["value"]["msg"].str); stderr.writeln(`::gendoc-request::{ "type": "ReqInfo", "value": {} }`); res = stdin.readln(); writeln(parseJSON(res)["value"]["dubPkgInfos"][0]["packageVersion"].str); }]); assert(pipe.stderr.equal(["test1", "test2"])); assert(pipe.stdout.equal(["xxx", "test-echo", "Unknown request type.", "v1.2.3"])); assert(pipe.result.equal(["xxx", "test1", "test2", "test-echo", "Unknown request type.", "v1.2.3"])); assert(pipe.status == 0);
Communicate with the launched program through stdio pipes.
gendoc responds to requests from the launched guest program. One request or response communicates via a JSON object without lines. Guest program requests are passed line by line to the standard error output. gendoc responds to requests with one line. The request starts with ::gendoc-request::, followed by a JSON string.
The response type corresponds to the request type.
| Request Type | Response Type | |:----------------------|:---------------------| | ReqEcho | ResEcho, ResErr | | ReqInfo | ResInfo, ResErr |
Each piece of information is composed of a JSON object composed of type and value as follows, and the value includes a payload. The following examples include line breaks and indents for readability, but do not break lines in the data actually used.