-
Notifications
You must be signed in to change notification settings - Fork 79
Add close option for compose group commands #363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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>; | ||||||
|
|
@@ -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); | ||||||
|
|
@@ -72,6 +73,7 @@ async function composeGroup<TOptions extends CommonOrchestratorCommandOptions>( | |||||
| const taskCRF = new TaskCommandRunnerFactory({ | ||||||
| taskName: client.displayName, | ||||||
| cwd: workingDirectory, | ||||||
| ...(close !== undefined && { close }), | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Haven't tried but I think this would work?
Suggested change
|
||||||
| }); | ||||||
|
|
||||||
| await taskCRF.getCommandRunner()(composeCommandCallback(client, options)); | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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`) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -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
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const taskExecution = await vscode.tasks.executeTask(task); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
There was a problem hiding this comment.
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
advancedtag, 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.