feat(cli): add action management commands
Added comprehensive action management: Commands: - nupst action add <ups-id> - Add a new action to a UPS interactively - nupst action remove <ups-id> <index> - Remove an action by index - nupst action list [ups-id] - List all actions (optionally for specific UPS) Features: - Interactive prompts for action configuration - Battery and runtime threshold configuration - Trigger mode selection (onlyPowerChanges, onlyThresholds, powerChangesAndThresholds, anyChange) - Shutdown delay configuration - Table-based display of actions with indices - Support for managing actions across multiple UPS devices Implementation: - Created ActionHandler class in ts/cli/action-handler.ts - Integrated with existing CLI infrastructure - Added to nupst.ts, cli.ts, and help system - Proper TypeScript typing throughout Closes the gap where users had to manually edit config.json to manage actions.
This commit is contained in:
10
ts/nupst.ts
10
ts/nupst.ts
@@ -6,6 +6,7 @@ import { logger } from './logger.ts';
|
||||
import { UpsHandler } from './cli/ups-handler.ts';
|
||||
import { GroupHandler } from './cli/group-handler.ts';
|
||||
import { ServiceHandler } from './cli/service-handler.ts';
|
||||
import { ActionHandler } from './cli/action-handler.ts';
|
||||
import * as https from 'node:https';
|
||||
|
||||
/**
|
||||
@@ -19,6 +20,7 @@ export class Nupst {
|
||||
private readonly upsHandler: UpsHandler;
|
||||
private readonly groupHandler: GroupHandler;
|
||||
private readonly serviceHandler: ServiceHandler;
|
||||
private readonly actionHandler: ActionHandler;
|
||||
private updateAvailable: boolean = false;
|
||||
private latestVersion: string = '';
|
||||
|
||||
@@ -36,6 +38,7 @@ export class Nupst {
|
||||
this.upsHandler = new UpsHandler(this);
|
||||
this.groupHandler = new GroupHandler(this);
|
||||
this.serviceHandler = new ServiceHandler(this);
|
||||
this.actionHandler = new ActionHandler(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,6 +83,13 @@ export class Nupst {
|
||||
return this.serviceHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Action handler for action management
|
||||
*/
|
||||
public getActionHandler(): ActionHandler {
|
||||
return this.actionHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current version of NUPST
|
||||
* @returns The current version string
|
||||
|
Reference in New Issue
Block a user