UNPKG

@pagopa/dx-cli

Version:

A CLI useful to manage DX tools.

27 lines (26 loc) 1.3 kB
import { azure, loadConfig } from "@pagopa/dx-savemoney"; import { Command } from "commander"; export const makeSavemoneyCommand = () => new Command("savemoney") .description("Analyze Azure subscriptions and report unused or inefficient resources") .option("-c, --config <path>", "Path to configuration file (JSON)") .option("-f, --format <format>", "Report format: json, table, or detailed-json (default: table)", "table") .option("-l, --location <string>", "Preferred Azure location for resources", "italynorth") .option("-d, --days <number>", "Number of days for metrics analysis", "30") .option("-v, --verbose", "Enable verbose logging") .action(async function (options) { try { // Load configuration const config = await loadConfig(options.config); const finalConfig = { ...config, preferredLocation: options.location || config.preferredLocation, timespanDays: Number.parseInt(options.days, 10) || config.timespanDays, verbose: options.verbose || false, }; // Run analysis await azure.analyzeAzureResources(finalConfig, options.format); } catch (error) { this.error(`Analysis failed: ${error instanceof Error ? error.message : error}`); } });