Skip to content

Commit b4734e8

Browse files
authored
Filter extensions by category (microsoft#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
1 parent 3512f9e commit b4734e8

4 files changed

Lines changed: 15 additions & 3 deletions

File tree

resources/completions/zsh/_code

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ arguments=(
1717
'(- *)'{--telemetry}'[Shows all telemetry events which VS code collects.]'
1818
'--extensions-dir[set the root path for extensions]:root path:_directories'
1919
'--list-extensions[list the installed extensions]'
20+
'--category[filters instaled extension list by category, when using --list-extension]'
2021
'--show-versions[show versions of installed extensions, when using --list-extension]'
2122
'--install-extension[install an extension]:id or path:_files -g "*.vsix(-.)"'
2223
'--uninstall-extension[uninstall an extension]:id or path:_files -g "*.vsix(-.)"'

src/vs/code/node/cliProcessMain.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export class Main {
8686
await this.setInstallSource(argv['install-source']);
8787

8888
} else if (argv['list-extensions']) {
89-
await this.listExtensions(!!argv['show-versions']);
89+
await this.listExtensions(!!argv['show-versions'], argv['category']);
9090

9191
} else if (argv['install-extension']) {
9292
const arg = argv['install-extension'];
@@ -110,8 +110,17 @@ export class Main {
110110
return writeFile(this.environmentService.installSourcePath, installSource.slice(0, 30));
111111
}
112112

113-
private async listExtensions(showVersions: boolean): Promise<void> {
114-
const extensions = await this.extensionManagementService.getInstalled(ExtensionType.User);
113+
private async listExtensions(showVersions: boolean, category?: string): Promise<void> {
114+
let extensions = await this.extensionManagementService.getInstalled(ExtensionType.User);
115+
if (category) {
116+
extensions = extensions.filter(e => {
117+
if (e.manifest.categories) {
118+
const lowerCaseCategories: string[] = e.manifest.categories.map(c => c.toLowerCase());
119+
return lowerCaseCategories.indexOf(category.toLowerCase()) > -1;
120+
}
121+
return false;
122+
});
123+
}
115124
extensions.forEach(e => console.log(getId(e.manifest, showVersions)));
116125
}
117126

src/vs/platform/environment/common/environment.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export interface ParsedArgs {
4747
'disable-extension'?: string | string[];
4848
'list-extensions'?: boolean;
4949
'show-versions'?: boolean;
50+
'category'?: string;
5051
'install-extension'?: string | string[];
5152
'uninstall-extension'?: string | string[];
5253
'locate-extension'?: string | string[];

src/vs/platform/environment/node/argv.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export const options: Option[] = [
4848
{ id: 'extensions-dir', type: 'string', deprecates: 'extensionHomePath', cat: 'e', args: 'dir', description: localize('extensionHomePath', "Set the root path for extensions.") },
4949
{ id: 'list-extensions', type: 'boolean', cat: 'e', description: localize('listExtensions', "List the installed extensions.") },
5050
{ id: 'show-versions', type: 'boolean', cat: 'e', description: localize('showVersions', "Show versions of installed extensions, when using --list-extension.") },
51+
{ id: 'category', type: 'string', cat: 'e', description: localize('category', "Filters installed extensions by provided category, when using --list-extension.") },
5152
{ 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.") },
5253
{ id: 'uninstall-extension', type: 'string', cat: 'e', args: 'extension-id', description: localize('uninstallExtension', "Uninstalls an extension.") },
5354
{ 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.") },

0 commit comments

Comments
 (0)