介面:ExtensionHost
目錄
自
0.2.0
屬性
cli
• 唯讀
cli: ExtensionCli
在主機中執行指令。
例如,在主機中執行內建的二進位檔案 `kubectl -h` 指令
await ddClient.extension.host.cli.exec("kubectl", ["-h"]);
串流在後端容器或主機中執行的指令輸出。
如果 `kubectl` 二進位檔案是您的擴充功能的一部分,您可以在主機中產生 `kubectl -h` 指令
await ddClient.extension.host.cli.exec("kubectl", ["-h"], {
stream: {
onOutput(data): void {
// As we can receive both `stdout` and `stderr`, we wrap them in a JSON object
JSON.stringify(
{
stdout: data.stdout,
stderr: data.stderr,
},
null,
" "
);
},
onError(error: any): void {
console.error(error);
},
onClose(exitCode: number): void {
console.log("onClose with exit code " + exitCode);
},
},
});