gendoc.cmdpipe
Command pipe
Communicate with the launched program commands through stdio pipes.
- struct
CommandPipe; - 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.::gendoc-request::{ "type": "ReqEcho", "value": {"msg": "test"} }The response type corresponds to the request type.
Each piece of information is composed of a JSON object composed ofRequest Type Response Type ReqEcho ResEcho, ResErr ReqInfo ResInfo, ResErr typeandvalueas follows, and thevalueincludes a payload. The following examples include line breaks and indents for readability, but do not break lines in the data actually used.{ "type": "ReqInfo", "value": { } }Examples: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);
- this(in ref Config cfg, in DubPkgInfo[] pkgInfo);
 - void
run(string[] args, string workDir = null, string[string] env = null);
voidrun(string args, string workDir = null, string[string] env = null); - const @property auto
result(); - const @property auto
stdout(); - const @property auto
stderr(); - const @property int
status(); 
 - struct
ReqEcho; - Test request to return the specified msg without processing.The main return value is ResEcho. ResErr will be returned if something goes wrong.Returns:
- ResEcho
 - ResErr
 
- string
msg; 
 - struct
ResEcho; - Main return value of ReqEcho
- string
msg; 
 - struct
ReqInfo; - Request information that gendoc has.The main return value is ResInfo. ResErr will be returned if something goes wrong.Returns:
- ResInfo
 - ResErr
 
 - struct
ResInfo; - Main return value of ReqInfo
 - struct
ResErr; - Return-value when something wrong.
- string
msg;