Filter extensions by category (#77306)

* Revert commit change

* Revert commit change

* Revert commit change

* Revert commit change

* Revert commit change

* Revert commit change

* Provide option to filter by category

* ignore casing

* Remove unwanted build change
This commit is contained in:
Logan Ramos 2019-07-23 07:29:35 -07:00 committed by GitHub
parent 3512f9e82c
commit b4734e8524
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 3 deletions

View file

@ -17,6 +17,7 @@ arguments=(
'(- *)'{--telemetry}'[Shows all telemetry events which VS code collects.]'
'--extensions-dir[set the root path for extensions]:root path:_directories'
'--list-extensions[list the installed extensions]'
'--category[filters instaled extension list by category, when using --list-extension]'
'--show-versions[show versions of installed extensions, when using --list-extension]'
'--install-extension[install an extension]:id or path:_files -g "*.vsix(-.)"'
'--uninstall-extension[uninstall an extension]:id or path:_files -g "*.vsix(-.)"'

View file

@ -86,7 +86,7 @@ export class Main {
await this.setInstallSource(argv['install-source']);
} else if (argv['list-extensions']) {
await this.listExtensions(!!argv['show-versions']);
await this.listExtensions(!!argv['show-versions'], argv['category']);
} else if (argv['install-extension']) {
const arg = argv['install-extension'];
@ -110,8 +110,17 @@ export class Main {
return writeFile(this.environmentService.installSourcePath, installSource.slice(0, 30));
}
private async listExtensions(showVersions: boolean): Promise<void> {
const extensions = await this.extensionManagementService.getInstalled(ExtensionType.User);
private async listExtensions(showVersions: boolean, category?: string): Promise<void> {
let extensions = await this.extensionManagementService.getInstalled(ExtensionType.User);
if (category) {
extensions = extensions.filter(e => {
if (e.manifest.categories) {
const lowerCaseCategories: string[] = e.manifest.categories.map(c => c.toLowerCase());
return lowerCaseCategories.indexOf(category.toLowerCase()) > -1;
}
return false;
});
}
extensions.forEach(e => console.log(getId(e.manifest, showVersions)));
}

View file

@ -47,6 +47,7 @@ export interface ParsedArgs {
'disable-extension'?: string | string[];
'list-extensions'?: boolean;
'show-versions'?: boolean;
'category'?: string;
'install-extension'?: string | string[];
'uninstall-extension'?: string | string[];
'locate-extension'?: string | string[];

View file

@ -48,6 +48,7 @@ export const options: Option[] = [
{ id: 'extensions-dir', type: 'string', deprecates: 'extensionHomePath', cat: 'e', args: 'dir', description: localize('extensionHomePath', "Set the root path for extensions.") },
{ id: 'list-extensions', type: 'boolean', cat: 'e', description: localize('listExtensions', "List the installed extensions.") },
{ id: 'show-versions', type: 'boolean', cat: 'e', description: localize('showVersions', "Show versions of installed extensions, when using --list-extension.") },
{ id: 'category', type: 'string', cat: 'e', description: localize('category', "Filters installed extensions by provided category, when using --list-extension.") },
{ id: 'install-extension', type: 'string', cat: 'e', args: 'extension-id | path-to-vsix', description: localize('installExtension', "Installs or updates the extension. Use `--force` argument to avoid prompts.") },
{ id: 'uninstall-extension', type: 'string', cat: 'e', args: 'extension-id', description: localize('uninstallExtension', "Uninstalls an extension.") },
{ id: 'enable-proposed-api', type: 'string', cat: 'e', args: 'extension-id', description: localize('experimentalApis', "Enables proposed API features for extensions. Can receive one or more extension IDs to enable individually.") },