import Foundation
import SiliconPulseCore

let command = CommandLine.arguments.dropFirst().first ?? "snapshot"

switch command {
case "snapshot":
    let snapshot = SystemSnapshotReader().read()
    print("thermalState=\(snapshot.thermalState.rawValue)")
    print("memoryPressureLevel=\(snapshot.memoryPressureLevel.rawValue)")
    print("memoryPressure=\(Int((snapshot.memoryPressureFraction * 100).rounded()))%")
    print("cpuC=\(snapshot.cpuTemperatureCelsius.map { String(format: "%.1f", $0) } ?? "unavailable")")
    print("gpuC=\(snapshot.gpuTemperatureCelsius.map { String(format: "%.1f", $0) } ?? "unavailable")")
default:
    fputs("Usage: SiliconPulseCLI snapshot\n", stderr)
    Foundation.exit(64)
}
