Update: Refactored commands into their own source files.
This commit is contained in:
89
src/cli.ts
89
src/cli.ts
@@ -4,6 +4,15 @@
|
||||
import { parseArgs } from "node:util";
|
||||
|
||||
import { runCommand } from "./cli/commands.ts";
|
||||
import { usageGetToken } from "./cli/commands/get-token.ts";
|
||||
import { usageListAppGrants } from "./cli/commands/list-app-grants.ts";
|
||||
import { usageListAppPermissions } from "./cli/commands/list-app-permissions.ts";
|
||||
import { usageListApps } from "./cli/commands/list-apps.ts";
|
||||
import { usageListResourcePermissions } from "./cli/commands/list-resource-permissions.ts";
|
||||
import { usageLogin } from "./cli/commands/login.ts";
|
||||
import { usageLogout } from "./cli/commands/logout.ts";
|
||||
import { usageRest } from "./cli/commands/rest.ts";
|
||||
import { usageTable } from "./cli/commands/table.ts";
|
||||
import {
|
||||
normalizeOutputFormat,
|
||||
omitPermissionGuidColumns,
|
||||
@@ -57,86 +66,6 @@ Use: sk-az-tools --help <command>
|
||||
or: sk-az-tools <command> --help`;
|
||||
}
|
||||
|
||||
function usageListApps(): string {
|
||||
return `Usage: sk-az-tools list-apps [--display-name|-n <name>] [--app-id|-i <appId>] [--filter|-f <glob>] [global options]
|
||||
|
||||
Options:
|
||||
-n, --display-name <name> Get app by name
|
||||
-i, --app-id <appId> Get app by id
|
||||
-f, --filter <glob> Filter by app display name glob`;
|
||||
}
|
||||
|
||||
function usageLogin(): string {
|
||||
return `Usage: sk-az-tools login [--resources <csv>] [--use-device-code] [--no-browser] [--browser <name>] [--browser-profile <profile>] [global options]
|
||||
|
||||
Options:
|
||||
--resources <csv> Comma-separated resources: graph,devops,arm (default: all)
|
||||
--use-device-code Use device code flow instead of interactive flow
|
||||
--no-browser Do not launch browser; print interactive URL to stderr
|
||||
--browser <name> Browser keyword: brave|browser|browserPrivate|chrome|edge|firefox
|
||||
--browser-profile <name> Chromium profile name (e.g. Default, "Profile 1")`;
|
||||
}
|
||||
|
||||
function usageLogout(): string {
|
||||
return `Usage: sk-az-tools logout [--all] [global options]
|
||||
|
||||
Options:
|
||||
--all Clear login state and remove all cached accounts`;
|
||||
}
|
||||
|
||||
function usageGetToken(): string {
|
||||
return `Usage: sk-az-tools get-token --type|-t <azurerm|devops> [global options]
|
||||
|
||||
Options:
|
||||
-t, --type <value> Token type: azurerm|devops`;
|
||||
}
|
||||
|
||||
function usageRest(): string {
|
||||
return `Usage: sk-az-tools rest [--method <httpMethod>] --url <url> [--header <name: value>] [global options]
|
||||
|
||||
Options:
|
||||
--method <httpMethod> HTTP method (default: GET; examples: GET, POST, PATCH, DELETE)
|
||||
--url <url> Full URL to call
|
||||
--header <name: value> Extra request header; example: "Content-Type: application/json"
|
||||
|
||||
Authorization is added automatically for:
|
||||
management.azure.com Uses azurerm token
|
||||
dev.azure.com Uses devops token`;
|
||||
}
|
||||
|
||||
function usageListAppPermissions(): string {
|
||||
return `Usage: sk-az-tools list-app-permissions --app-id|-i <appId> [--resolve|-r] [--short|-s] [--filter|-f <glob>] [global options]
|
||||
|
||||
Options:
|
||||
-i, --app-id <appId> Application (client) ID (required)
|
||||
-r, --resolve Resolve permission GUIDs to human-readable values
|
||||
-s, --short Makes output more compact
|
||||
-f, --filter <glob> Filter by permission name glob`;
|
||||
}
|
||||
|
||||
function usageListAppGrants(): string {
|
||||
return `Usage: sk-az-tools list-app-grants --app-id|-i <appId> [global options]
|
||||
|
||||
Options:
|
||||
-i, --app-id <appId> Application (client) ID (required)`;
|
||||
}
|
||||
|
||||
function usageListResourcePermissions(): string {
|
||||
return `Usage: sk-az-tools list-resource-permissions [--app-id|-i <appId> | --display-name|-n <name>] [--filter|-f <glob>] [global options]
|
||||
|
||||
Options:
|
||||
-i, --app-id <appId> Resource app ID
|
||||
-n, --display-name <name> Resource app display name
|
||||
-f, --filter <glob> Filter by permission name glob`;
|
||||
}
|
||||
|
||||
function usageTable(): string {
|
||||
return `Usage: sk-az-tools table [--header|-H <spec|auto|a|original|o>] [global options]
|
||||
|
||||
Options:
|
||||
-H, --header <value> Header mode/spec: auto|a (default), original|o, OR "col1, col2" OR "key1: Label 1, key2: Label 2"`;
|
||||
}
|
||||
|
||||
function usageCommand(command: string): string {
|
||||
switch (command) {
|
||||
case "login":
|
||||
|
||||
Reference in New Issue
Block a user