2025-10-19 15:08:30 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Color theme and styling utilities for NUPST CLI
|
|
|
|
|
|
* Uses Deno standard library colors module
|
|
|
|
|
|
*/
|
|
|
|
|
|
import * as colors from '@std/fmt/colors';
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Color theme for consistent CLI styling
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const theme = {
|
|
|
|
|
|
// Message types
|
|
|
|
|
|
error: colors.red,
|
|
|
|
|
|
warning: colors.yellow,
|
|
|
|
|
|
success: colors.green,
|
|
|
|
|
|
info: colors.cyan,
|
|
|
|
|
|
dim: colors.dim,
|
|
|
|
|
|
highlight: colors.bold,
|
|
|
|
|
|
|
|
|
|
|
|
// Status indicators
|
|
|
|
|
|
statusActive: (text: string) => colors.green(colors.bold(text)),
|
|
|
|
|
|
statusInactive: (text: string) => colors.red(text),
|
|
|
|
|
|
statusWarning: (text: string) => colors.yellow(text),
|
|
|
|
|
|
statusUnknown: (text: string) => colors.dim(text),
|
|
|
|
|
|
|
|
|
|
|
|
// Battery level colors
|
|
|
|
|
|
batteryGood: colors.green, // > 60%
|
|
|
|
|
|
batteryMedium: colors.yellow, // 30-60%
|
|
|
|
|
|
batteryCritical: colors.red, // < 30%
|
|
|
|
|
|
|
|
|
|
|
|
// Box borders
|
|
|
|
|
|
borderSuccess: colors.green,
|
|
|
|
|
|
borderError: colors.red,
|
|
|
|
|
|
borderWarning: colors.yellow,
|
|
|
|
|
|
borderInfo: colors.cyan,
|
|
|
|
|
|
borderDefault: (text: string) => text, // No color
|
|
|
|
|
|
|
|
|
|
|
|
// Command/code highlighting
|
|
|
|
|
|
command: colors.cyan,
|
|
|
|
|
|
code: colors.dim,
|
|
|
|
|
|
path: colors.blue,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Status symbols with colors
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const symbols = {
|
|
|
|
|
|
success: colors.green('✓'),
|
|
|
|
|
|
error: colors.red('✗'),
|
|
|
|
|
|
warning: colors.yellow('⚠'),
|
|
|
|
|
|
info: colors.cyan('ℹ'),
|
|
|
|
|
|
running: colors.green('●'),
|
|
|
|
|
|
stopped: colors.red('○'),
|
|
|
|
|
|
starting: colors.yellow('◐'),
|
|
|
|
|
|
unknown: colors.dim('◯'),
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Get color for battery level
|
|
|
|
|
|
*/
|
|
|
|
|
|
export function getBatteryColor(percentage: number): (text: string) => string {
|
|
|
|
|
|
if (percentage >= 60) return theme.batteryGood;
|
|
|
|
|
|
if (percentage >= 30) return theme.batteryMedium;
|
|
|
|
|
|
return theme.batteryCritical;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Get color for runtime remaining
|
|
|
|
|
|
*/
|
|
|
|
|
|
export function getRuntimeColor(minutes: number): (text: string) => string {
|
|
|
|
|
|
if (minutes >= 20) return theme.batteryGood;
|
|
|
|
|
|
if (minutes >= 10) return theme.batteryMedium;
|
|
|
|
|
|
return theme.batteryCritical;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Format UPS power status with color
|
|
|
|
|
|
*/
|
2026-04-16 09:44:30 +00:00
|
|
|
|
export function formatPowerStatus(
|
|
|
|
|
|
status: 'online' | 'onBattery' | 'unknown' | 'unreachable',
|
|
|
|
|
|
): string {
|
2025-10-19 15:08:30 +00:00
|
|
|
|
switch (status) {
|
|
|
|
|
|
case 'online':
|
|
|
|
|
|
return theme.success('Online');
|
|
|
|
|
|
case 'onBattery':
|
|
|
|
|
|
return theme.warning('On Battery');
|
2026-02-20 11:51:59 +00:00
|
|
|
|
case 'unreachable':
|
|
|
|
|
|
return theme.error('Unreachable');
|
2025-10-19 15:08:30 +00:00
|
|
|
|
case 'unknown':
|
|
|
|
|
|
default:
|
|
|
|
|
|
return theme.dim('Unknown');
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|