Added more filtering options to app listing.

This commit is contained in:
2026-02-08 15:26:24 +01:00
parent 400d418763
commit 5888cb4d1a
3 changed files with 31 additions and 6 deletions

View File

@@ -20,6 +20,12 @@ function filterByPermissionName(rows, pattern) {
);
}
function filterByDisplayName(rows, pattern) {
return rows.filter((item) =>
minimatch(item.displayName ?? "", pattern, { nocase: true })
);
}
async function getGraphClientFromPublicConfig() {
const config = await loadPublicConfig();
return getGraphClient({
@@ -34,9 +40,17 @@ async function runTableCommand() {
async function runListAppsCommand(values) {
const { client } = await getGraphClientFromPublicConfig();
return listApps(client, {
let result = await listApps(client, {
displayName: values["display-name"],
appId: values["app-id"],
});
if (values["app-id"] && result.length > 1) {
throw new Error(`Expected a single app for --app-id ${values["app-id"]}, but got ${result.length}`);
}
if (values.filter) {
result = filterByDisplayName(result, values.filter);
}
return result;
}
async function runListAppPermissionsCommand(values) {