Skip to content

workbench: Adds 'Show Code Version' Action #40745

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

Merged
Merged
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
21 changes: 21 additions & 0 deletions src/vs/workbench/parts/cli/electron-browser/cli.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(code: string, value: T = null): (err: any) => TPromise<T> {
return err => err.code === code ? TPromise.as<T>(value) : TPromise.wrapError<T>(err);
Expand Down Expand Up @@ -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<void> {
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<IWorkbenchActionRegistry>(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);
}