The daemon already has automatic config file watching and reloads changes
without requiring a restart. Updated action handler messages to correctly
reflect this behavior.
Changed:
- 'Restart service to apply changes: nupst service restart'
→ 'Changes saved and will be applied automatically'
The config file watcher (daemon.ts:986) uses Deno.watchFs() to monitor
/etc/nupst/config.json and automatically calls reloadConfig() when changes
are detected. No restart needed.
Extended action management to support groups in addition to UPS devices:
Changes:
- Auto-detects whether target ID is a UPS or group
- All action commands now work with both UPS and groups:
* nupst action add <ups-id|group-id>
* nupst action remove <ups-id|group-id> <index>
* nupst action list [ups-id|group-id]
- Updated ActionHandler methods to handle both target types
- Updated help text and usage examples
- List command shows both UPS and group actions when no target specified
- Clear labeling in output distinguishes UPS actions from group actions
Example usage:
nupst action list # Shows all UPS and group actions
nupst action add dc-rack-1 # Adds action to group 'dc-rack-1'
nupst action remove default 0 # Removes action from UPS 'default'
Groups can now have their own shutdown actions, allowing fine-grained
control over group behavior during power events.
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.