List possible categories (#78198)

* List possible categories

* TODO comment

* Message if category is invalid
This commit is contained in:
Logan Ramos
2019-07-30 09:06:23 -07:00
committed by GitHub
parent f2b65a9601
commit b54d772562

View File

@@ -112,7 +112,13 @@ export class Main {
private async listExtensions(showVersions: boolean, category?: string): Promise<void> {
let extensions = await this.extensionManagementService.getInstalled(ExtensionType.User);
if (category) {
// TODO: we should save this array in a common place so that the command and extensionQuery can use it that way changing it is easier
const categories = ['"programming languages"', 'snippets', 'linters', 'themes', 'debuggers', 'formatters', 'keymaps', '"scm providers"', 'other', '"extension packs"', '"language packs"'];
if (category && category !== '') {
if (categories.indexOf(category.toLowerCase()) < 0) {
console.log('Invalid category please enter a valid category. To list valid categories run --category without a category specified');
return;
}
extensions = extensions.filter(e => {
if (e.manifest.categories) {
const lowerCaseCategories: string[] = e.manifest.categories.map(c => c.toLowerCase());
@@ -120,6 +126,12 @@ export class Main {
}
return false;
});
} else if (category === '') {
console.log('Possible Categories: ');
categories.forEach(category => {
console.log(category);
});
return;
}
extensions.forEach(e => console.log(getId(e.manifest, showVersions)));
}
@@ -369,4 +381,4 @@ export async function main(argv: ParsedArgs): Promise<void> {
disposables.dispose();
}
});
}
}