Migrated from parseArgs from node:util to commander.js.
All checks were successful
build / build (push) Successful in 14s
All checks were successful
build / build (push) Successful in 14s
This commit is contained in:
@@ -3,7 +3,12 @@
|
||||
import { listResourcePermissions } from "../../graph/app.ts";
|
||||
import { getGraphClient } from "../../graph/index.ts";
|
||||
import { filterByPermissionName } from "./shared.ts";
|
||||
import type { CommandValues } from "./types.ts";
|
||||
|
||||
type ListResourcePermissionsOptions = {
|
||||
appId?: string;
|
||||
displayName?: string;
|
||||
filter?: string;
|
||||
};
|
||||
|
||||
export function usageListResourcePermissions(): string {
|
||||
return `Usage: sk-az-tools list-resource-permissions [--app-id|-i <appId> | --display-name|-n <name>] [--filter|-f <glob>] [global options]
|
||||
@@ -14,22 +19,22 @@ Options:
|
||||
--filter, -f <glob> Filter by permission name glob`;
|
||||
}
|
||||
|
||||
export async function runListResourcePermissionsCommand(values: CommandValues): Promise<unknown> {
|
||||
if (!values["app-id"] && !values["display-name"]) {
|
||||
export async function runListResourcePermissionsCommand(options: ListResourcePermissionsOptions): Promise<unknown> {
|
||||
if (!options.appId && !options.displayName) {
|
||||
throw new Error("--app-id or --display-name is required for list-resource-permissions");
|
||||
}
|
||||
if (values["app-id"] && values["display-name"]) {
|
||||
if (options.appId && options.displayName) {
|
||||
throw new Error("Use either --app-id or --display-name for list-resource-permissions, not both");
|
||||
}
|
||||
|
||||
const client = await getGraphClient();
|
||||
let result = await listResourcePermissions(
|
||||
client,
|
||||
values["app-id"],
|
||||
values["display-name"],
|
||||
options.appId,
|
||||
options.displayName,
|
||||
);
|
||||
if (values.filter) {
|
||||
result = filterByPermissionName(result, values.filter);
|
||||
if (options.filter) {
|
||||
result = filterByPermissionName(result, options.filter);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user