Added more filtering options to app listing.
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user