跳转到主内容

commands

commands 模块提供用于注册和执行命令的函数。现有的命令可供扩展使用。

  • pullImage:使用 Podman Desktop 的 UI 拉取镜像行为。此命令将创建一个可见的任务来显示 pullImage 操作的进度,并可选择包含一个任务操作。它使用与原始 pullImage 函数相同的参数,此外还具有 taskActionName: stringtaskActionCallback: () => void 作为创建任务操作的参数(可选)。

示例

import * as api from '@podman-desktop/api';

export async function activate(extensionContext: api.ExtensionContext): Promise<void> {

const myCommand = api.commands.registerCommand(
'extension-name.my-command',
(arg1: string, arg2: number) => {
console.log('my-command executed with', arg1, arg2);
},
);

extensionContext.subscriptions.push(myCommand);

// [...]

api.commands.executeCommand('extension-name.my-command', 'a-string', 1001);
}

函数