Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ async function compose(context: IActionContext, commands: ('up' | 'down' | 'upSu
const taskCRF = new TaskCommandRunnerFactory({
taskName: client.displayName,
workspaceFolder: folder,
close: true,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think at a minimum, this needs to be a setting (probably advanced tag, default false). Compose Up can include pulling and building images and that's something users may want to look back at after completion (even successful completion).

The same applies for probably all of these except for logOutOfDockerCli, which I think is fine to always close.

});

await taskCRF.getCommandRunner()(terminalCommand);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ export async function composeGroupLogs(context: IActionContext, node: ContainerG
}

export async function composeGroupStart(context: IActionContext, node: ContainerGroupTreeItem): Promise<void> {
return composeGroup(context, (client, options) => client.start(options), node);
return composeGroup(context, (client, options) => client.start(options), node, undefined, true);
}

export async function composeGroupStop(context: IActionContext, node: ContainerGroupTreeItem): Promise<void> {
return composeGroup(context, (client, options) => client.stop(options), node);
return composeGroup(context, (client, options) => client.stop(options), node, undefined, true);
}

export async function composeGroupRestart(context: IActionContext, node: ContainerGroupTreeItem): Promise<void> {
return composeGroup(context, (client, options) => client.restart(options), node);
return composeGroup(context, (client, options) => client.restart(options), node, undefined, true);
}

export async function composeGroupDown(context: IActionContext, node: ContainerGroupTreeItem): Promise<void> {
return composeGroup(context, (client, options) => client.down(options), node);
return composeGroup(context, (client, options) => client.down(options), node, undefined, true);
}

type AdditionalOptions<TOptions extends CommonOrchestratorCommandOptions> = Omit<TOptions, keyof CommonOrchestratorCommandOptions>;
Expand All @@ -39,7 +39,8 @@ async function composeGroup<TOptions extends CommonOrchestratorCommandOptions>(
context: IActionContext,
composeCommandCallback: (client: IContainerOrchestratorClient, options: TOptions) => Promise<VoidCommandResponse>,
node: ContainerGroupTreeItem,
additionalOptions?: AdditionalOptions<TOptions>
additionalOptions?: AdditionalOptions<TOptions>,
close?: boolean
): Promise<void> {
if (!node) {
await ext.containersTree.refresh(context);
Expand Down Expand Up @@ -72,6 +73,7 @@ async function composeGroup<TOptions extends CommonOrchestratorCommandOptions>(
const taskCRF = new TaskCommandRunnerFactory({
taskName: client.displayName,
cwd: workingDirectory,
...(close !== undefined && { close }),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't tried but I think this would work?

Suggested change
...(close !== undefined && { close }),
{ close },

});

await taskCRF.getCommandRunner()(composeCommandCallback(client, options));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export async function buildImage(context: IActionContext, dockerFileUri: vscode.
taskName: client.displayName,
workspaceFolder: rootFolder,
focus: true,
close: true,
});

await taskCRF.getCommandRunner()(terminalCommand);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export async function pullImage(context: IActionContext, node?: ImageTreeItem, n
const client = await ext.runtimeManager.getClient();
const taskCRF = new TaskCommandRunnerFactory(
{
taskName: l10n.t('Pull images')
taskName: l10n.t('Pull images'),
close: true,
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export class ImagePushStep extends AzureWizardExecuteStep<PushImageWizardContext
const client = await ext.runtimeManager.getClient();
const taskCRF = new TaskCommandRunnerFactory(
{
taskName: wizardContext.finalTag
taskName: wizardContext.finalTag,
close: true,
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ async function runImageCore(context: IActionContext, node: ImageTreeItem | undef
{
taskName: node.fullTag === '<none>' ? node.imageId : node.fullTag,
alwaysRunNew: interactive,
close: !interactive,
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export async function logOutOfDockerCli(context: IActionContext, node?: UnifiedR
const client = await ext.runtimeManager.getClient();
const taskCRF = new TaskCommandRunnerFactory(
{
taskName: 'Container Tools'
taskName: 'Container Tools',
close: true,
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ async function pullImages(context: IActionContext, node: UnifiedRegistryItem<unk
const client = await ext.runtimeManager.getClient();
const taskCRF = new TaskCommandRunnerFactory({
taskName: client.displayName,
close: true,
});
Comment on lines 35 to 39

await taskCRF.getCommandRunner()(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface TaskCommandRunnerOptions {
alwaysRunNew?: boolean;
rejectOnError?: boolean;
focus?: boolean;
close?: boolean; // When true, auto-close the terminal when the task completes. Default is false.
env?: never; // Environment is not needed and should not be used, because VSCode adds it already (due to using `ExtensionContext.environmentVariableCollection`)
}

Expand Down Expand Up @@ -57,10 +58,15 @@ async function executeAsTask(options: TaskCommandRunnerOptions, command: string,
task.definition.idRandomizer = Math.random();
}

if (options.focus) {
task.presentationOptions = {
focus: true,
};
if (options.focus || options.close) {
const presentationOptions: vscode.TaskPresentationOptions = {};
if (options.focus) {
presentationOptions.focus = true;
}
if (options.close) {
presentationOptions.close = true;
}
task.presentationOptions = presentationOptions;
}
Comment on lines +61 to 70
Comment on lines +61 to 70

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be tested to be sure, but I'd be surprised if this was semantically any different from this, which is much cleaner reading IMO:

Suggested change
if (options.focus || options.close) {
const presentationOptions: vscode.TaskPresentationOptions = {};
if (options.focus) {
presentationOptions.focus = true;
}
if (options.close) {
presentationOptions.close = true;
}
task.presentationOptions = presentationOptions;
}
task.presentationOptions = {
focus: options.focus,
close: options.close,
};


const taskExecution = await vscode.tasks.executeTask(task);
Expand Down