From 368785be90dcdc978d360966f00a27549d95382f Mon Sep 17 00:00:00 2001 From: Shobhit Chittora Date: Sat, 23 Dec 2017 11:52:41 +0530 Subject: [PATCH] workbench: Adds 'Show Code Version' Action --- .../cli/electron-browser/cli.contribution.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/vs/workbench/parts/cli/electron-browser/cli.contribution.ts b/src/vs/workbench/parts/cli/electron-browser/cli.contribution.ts index af31a3e601a60..9ea1e4a7d4cc9 100644 --- a/src/vs/workbench/parts/cli/electron-browser/cli.contribution.ts +++ b/src/vs/workbench/parts/cli/electron-browser/cli.contribution.ts @@ -16,6 +16,7 @@ import { Registry } from 'vs/platform/registry/common/platform'; import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; import { IMessageService, Severity } from 'vs/platform/message/common/message'; import product from 'vs/platform/node/product'; +import IPackageConfiguration from 'vs/platform/node/package'; function ignore(code: string, value: T = null): (err: any) => TPromise { return err => err.code === code ? TPromise.as(value) : TPromise.wrapError(err); @@ -143,10 +144,30 @@ class UninstallAction extends Action { } } +class ShowCodeVersion extends Action { + public static readonly ID = 'workbench.action.showCodeVersion'; + public static LABEL = nls.localize('version', "Show version of '{0}' installed", product.applicationName); + + constructor( + id: string, + label: string, + @IMessageService private messageService: IMessageService + ) { + super(id, label); + } + + + run(): TPromise { + this.messageService.show(Severity.Info, nls.localize('successFromVersion', "'{0}' version - {1}", product.applicationName, IPackageConfiguration.version)); + return TPromise.as(null); + } +} + if (process.platform === 'darwin') { const category = nls.localize('shellCommand', "Shell Command"); const workbenchActionsRegistry = Registry.as(ActionExtensions.WorkbenchActions); workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(InstallAction, InstallAction.ID, InstallAction.LABEL), 'Shell Command: Install \'code\' command in PATH', category); workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(UninstallAction, UninstallAction.ID, UninstallAction.LABEL), 'Shell Command: Uninstall \'code\' command from PATH', category); + workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ShowCodeVersion, ShowCodeVersion.ID, ShowCodeVersion.LABEL), 'Shell Command: Show \'code\' version', category); }