提交 e0bd67ed 编写于 作者: G greams

Add option for --list-extensions arg

- Updates listExtensions() and getId() for optional params showVersions / withVersion
- Adds --help info for new option

Resolves: #12963
上级 602155bb
......@@ -36,8 +36,12 @@ const notFound = id => localize('notFound', "Extension '{0}' not found.", id);
const notInstalled = id => localize('notInstalled', "Extension '{0}' is not installed.", id);
const useId = localize('useId', "Make sure you use the full extension ID, including the publisher, eg: {0}", 'ms-vscode.csharp');
function getId(manifest: IExtensionManifest): string {
return `${ manifest.publisher }.${ manifest.name }`;
function getId(manifest: IExtensionManifest, withVersion?: boolean): string {
if (withVersion) {
return `${ manifest.publisher }.${ manifest.name } v${ manifest.version }`;
} else {
return `${ manifest.publisher }.${ manifest.name }`;
}
}
type Task = { ():TPromise<void> };
......@@ -53,7 +57,7 @@ class Main {
// TODO@joao - make this contributable
if (argv['list-extensions']) {
return this.listExtensions();
return this.listExtensions(argv['show-versions']);
} else if (argv['install-extension']) {
const arg = argv['install-extension'];
const args: string[] = typeof arg === 'string' ? [arg] : arg;
......@@ -65,9 +69,9 @@ class Main {
}
}
private listExtensions(): TPromise<any> {
private listExtensions(showVersions: boolean): TPromise<any> {
return this.extensionManagementService.getInstalled(LocalExtensionType.User).then(extensions => {
extensions.forEach(e => console.log(getId(e.manifest)));
extensions.forEach(e => console.log(getId(e.manifest, showVersions)));
});
}
......
......@@ -29,6 +29,7 @@ export interface ParsedArgs extends minimist.ParsedArgs {
debugBrkPluginHost?: string;
debugPluginHost?: string;
'list-extensions'?: boolean;
'show-versions'?: boolean;
'install-extension'?: string | string[];
'uninstall-extension'?: string | string[];
'open-url'?: string | string[];
......@@ -59,7 +60,8 @@ const options: minimist.Opts = {
'verbose',
'logExtensionHostCommunication',
'disable-extensions',
'list-extensions'
'list-extensions',
'show-versions'
],
alias: {
help: 'h',
......@@ -136,6 +138,7 @@ export const optionsHelp: { [name: string]: string; } = {
'-w, --wait': localize('wait', "Wait for the window to be closed before returning."),
'--extensionHomePath': localize('extensionHomePath', "Set the root path for extensions."),
'--list-extensions': localize('listExtensions', "List the installed extensions."),
'--show-versions': localize('showVersions', "Show version of installed extension. Requires --list-extension."),
'--install-extension <ext>': localize('installExtension', "Installs an extension."),
'--uninstall-extension <ext>': localize('uninstallExtension', "Uninstalls an extension."),
'--disable-extensions': localize('disableExtensions', "Disable all installed extensions."),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册