|
1 | 1 | import { Command } from 'commander'; |
2 | | -import { installService, uninstallService, startService, stopService, isServiceInstalled, isServiceRunning, updateServiceBinPath } from '../system/service.js'; |
| 2 | +import { installService, uninstallService, startService, stopService, isServiceInstalled, isServiceRunning, updateServiceBinPath, setServiceStartupType } from '../system/service.js'; |
3 | 3 | import { logger } from '../core/logger.js'; |
4 | 4 |
|
5 | 5 | export const serviceCommand = new Command('service') |
@@ -95,3 +95,29 @@ serviceCommand.command('status') |
95 | 95 | process.exit(1); |
96 | 96 | } |
97 | 97 | }); |
| 98 | + |
| 99 | +serviceCommand.command('startup') |
| 100 | + .description('Set Service Startup Type') |
| 101 | + .argument('<type>', 'Startup type (automatic, manual, disabled, delayed)') |
| 102 | + .action(async (type) => { |
| 103 | + const validTypes = ['automatic', 'manual', 'disabled', 'delayed']; |
| 104 | + const normalizedType = type.toLowerCase(); |
| 105 | + |
| 106 | + if (!validTypes.includes(normalizedType)) { |
| 107 | + logger.error(`Invalid startup type. Must be one of: ${validTypes.join(', ')}`); |
| 108 | + process.exit(1); |
| 109 | + } |
| 110 | + |
| 111 | + try { |
| 112 | + const typeMap: Record<string, 'Automatic' | 'Manual' | 'Disabled' | 'Delayed'> = { |
| 113 | + 'automatic': 'Automatic', |
| 114 | + 'manual': 'Manual', |
| 115 | + 'disabled': 'Disabled', |
| 116 | + 'delayed': 'Delayed' |
| 117 | + }; |
| 118 | + await setServiceStartupType(typeMap[normalizedType]); |
| 119 | + } catch (error) { |
| 120 | + logger.error('Failed to set startup type', error); |
| 121 | + process.exit(1); |
| 122 | + } |
| 123 | + }); |
0 commit comments