Phase 3: Reorganize CLI with subcommand structure
Major Changes: - Reorganized commands into logical groups (service, ups, group) - Added new subcommand structure: - nupst service <enable|disable|start|stop|restart|status|logs|start-daemon> - nupst ups <add|edit|remove|list|test> - nupst group <add|edit|remove|list> - nupst config [show] - Added --version/-v flag support - Added restart subcommand for service - Added command aliases (ls, rm) - Renamed delete() to remove() in handlers - Maintained backward compatibility with deprecation warnings - Updated all help messages to reflect new structure - Added showVersion(), showServiceHelp(), showUpsHelp() methods - Fixed readline imports to use node:readline Breaking Changes: - Old command format (e.g. 'nupst add') is deprecated - Users should migrate to new format (e.g. 'nupst ups add') - Backward compatibility maintained with warnings for now
This commit is contained in:
@@ -88,7 +88,7 @@ export class GroupHandler {
|
||||
public async add(): Promise<void> {
|
||||
try {
|
||||
// Import readline module for user input
|
||||
const readline = await import('readline');
|
||||
const readline = await import('node:readline');
|
||||
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
@@ -198,7 +198,7 @@ export class GroupHandler {
|
||||
public async edit(groupId: string): Promise<void> {
|
||||
try {
|
||||
// Import readline module for user input
|
||||
const readline = await import('readline');
|
||||
const readline = await import('node:readline');
|
||||
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
@@ -306,7 +306,7 @@ export class GroupHandler {
|
||||
* Delete an existing UPS group
|
||||
* @param groupId ID of the group to delete
|
||||
*/
|
||||
public async delete(groupId: string): Promise<void> {
|
||||
public async remove(groupId: string): Promise<void> {
|
||||
try {
|
||||
// Try to load configuration
|
||||
try {
|
||||
@@ -335,7 +335,7 @@ export class GroupHandler {
|
||||
const groupToDelete = config.groups[groupIndex];
|
||||
|
||||
// Get confirmation before deleting
|
||||
const readline = await import('readline');
|
||||
const readline = await import('node:readline');
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
|
@@ -24,7 +24,7 @@ export class UpsHandler {
|
||||
public async add(): Promise<void> {
|
||||
try {
|
||||
// Import readline module for user input
|
||||
const readline = await import('readline');
|
||||
const readline = await import('node:readline');
|
||||
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
@@ -155,7 +155,7 @@ export class UpsHandler {
|
||||
public async edit(upsId?: string): Promise<void> {
|
||||
try {
|
||||
// Import readline module for user input
|
||||
const readline = await import('readline');
|
||||
const readline = await import('node:readline');
|
||||
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
@@ -284,7 +284,7 @@ export class UpsHandler {
|
||||
* Delete a UPS by ID
|
||||
* @param upsId ID of the UPS to delete
|
||||
*/
|
||||
public async delete(upsId: string): Promise<void> {
|
||||
public async remove(upsId: string): Promise<void> {
|
||||
try {
|
||||
// Try to load configuration
|
||||
try {
|
||||
@@ -318,7 +318,7 @@ export class UpsHandler {
|
||||
const upsToDelete = config.upsDevices[upsIndex];
|
||||
|
||||
// Get confirmation before deleting
|
||||
const readline = await import('readline');
|
||||
const readline = await import('node:readline');
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
|
Reference in New Issue
Block a user