style: configure deno fmt to use single quotes
- Add singleQuote: true to deno.json fmt configuration - Reformat all files with single quotes using deno fmt
This commit is contained in:
53
ts/cli.ts
53
ts/cli.ts
@@ -1,4 +1,4 @@
|
||||
import { execSync } from "node:child_process";
|
||||
import { execSync } from 'node:child_process';
|
||||
import { Nupst } from './nupst.ts';
|
||||
import { logger } from './logger.ts';
|
||||
|
||||
@@ -62,7 +62,11 @@ export class NupstCli {
|
||||
* @param commandArgs Additional command arguments
|
||||
* @param debugMode Whether debug mode is enabled
|
||||
*/
|
||||
private async executeCommand(command: string, commandArgs: string[], debugMode: boolean): Promise<void> {
|
||||
private async executeCommand(
|
||||
command: string,
|
||||
commandArgs: string[],
|
||||
debugMode: boolean,
|
||||
): Promise<void> {
|
||||
// Get access to the handlers
|
||||
const upsHandler = this.nupst.getUpsHandler();
|
||||
const groupHandler = this.nupst.getGroupHandler();
|
||||
@@ -87,7 +91,7 @@ export class NupstCli {
|
||||
break;
|
||||
case 'restart':
|
||||
await serviceHandler.stop();
|
||||
await new Promise(resolve => setTimeout(resolve, 2000)); // Wait 2s
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait 2s
|
||||
await serviceHandler.start();
|
||||
break;
|
||||
case 'status':
|
||||
@@ -263,7 +267,9 @@ export class NupstCli {
|
||||
await serviceHandler.logs();
|
||||
break;
|
||||
case 'daemon-start':
|
||||
logger.log("Note: 'nupst daemon-start' is deprecated. Use 'nupst service start-daemon' instead.");
|
||||
logger.log(
|
||||
"Note: 'nupst daemon-start' is deprecated. Use 'nupst service start-daemon' instead.",
|
||||
);
|
||||
await serviceHandler.daemonStart(debugMode);
|
||||
break;
|
||||
|
||||
@@ -328,8 +334,12 @@ export class NupstCli {
|
||||
logger.logBoxLine(`${ups.name} (${ups.id}):`);
|
||||
logger.logBoxLine(` Host: ${ups.snmp.host}:${ups.snmp.port}`);
|
||||
logger.logBoxLine(` Model: ${ups.snmp.upsModel}`);
|
||||
logger.logBoxLine(` Thresholds: ${ups.thresholds.battery}% battery, ${ups.thresholds.runtime} min runtime`);
|
||||
logger.logBoxLine(` Groups: ${ups.groups.length > 0 ? ups.groups.join(', ') : 'None'}`);
|
||||
logger.logBoxLine(
|
||||
` Thresholds: ${ups.thresholds.battery}% battery, ${ups.thresholds.runtime} min runtime`,
|
||||
);
|
||||
logger.logBoxLine(
|
||||
` Groups: ${ups.groups.length > 0 ? ups.groups.join(', ') : 'None'}`,
|
||||
);
|
||||
logger.logBoxLine('');
|
||||
}
|
||||
logger.logBoxEnd();
|
||||
@@ -344,11 +354,16 @@ export class NupstCli {
|
||||
if (group.description) {
|
||||
logger.logBoxLine(` Description: ${group.description}`);
|
||||
}
|
||||
|
||||
|
||||
// List UPS devices in this group
|
||||
const upsInGroup = config.upsDevices.filter(ups => ups.groups && ups.groups.includes(group.id));
|
||||
logger.logBoxLine(` UPS Devices: ${upsInGroup.length > 0 ?
|
||||
upsInGroup.map(ups => ups.name).join(', ') : 'None'}`);
|
||||
const upsInGroup = config.upsDevices.filter((ups) =>
|
||||
ups.groups && ups.groups.includes(group.id)
|
||||
);
|
||||
logger.logBoxLine(
|
||||
` UPS Devices: ${
|
||||
upsInGroup.length > 0 ? upsInGroup.map((ups) => ups.name).join(', ') : 'None'
|
||||
}`,
|
||||
);
|
||||
logger.logBoxLine('');
|
||||
}
|
||||
logger.logBoxEnd();
|
||||
@@ -390,11 +405,15 @@ export class NupstCli {
|
||||
// Show OIDs if custom model is selected
|
||||
if (config.snmp.upsModel === 'custom' && config.snmp.customOIDs) {
|
||||
logger.logBoxLine('Custom OIDs:');
|
||||
logger.logBoxLine(` Power Status: ${config.snmp.customOIDs.POWER_STATUS || 'Not set'}`);
|
||||
logger.logBoxLine(
|
||||
` Battery Capacity: ${config.snmp.customOIDs.BATTERY_CAPACITY || 'Not set'}`
|
||||
` Power Status: ${config.snmp.customOIDs.POWER_STATUS || 'Not set'}`,
|
||||
);
|
||||
logger.logBoxLine(
|
||||
` Battery Capacity: ${config.snmp.customOIDs.BATTERY_CAPACITY || 'Not set'}`,
|
||||
);
|
||||
logger.logBoxLine(
|
||||
` Battery Runtime: ${config.snmp.customOIDs.BATTERY_RUNTIME || 'Not set'}`,
|
||||
);
|
||||
logger.logBoxLine(` Battery Runtime: ${config.snmp.customOIDs.BATTERY_RUNTIME || 'Not set'}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,7 +454,11 @@ export class NupstCli {
|
||||
// Ignore errors checking service status
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error(`Failed to display configuration: ${error instanceof Error ? error.message : String(error)}`);
|
||||
logger.error(
|
||||
`Failed to display configuration: ${
|
||||
error instanceof Error ? error.message : String(error)
|
||||
}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,4 +607,4 @@ Examples:
|
||||
nupst group remove dc-1 - Remove group with ID 'dc-1'
|
||||
`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user