- Created deno.json configuration - Updated all imports to use npm:net-snmp@3.20.0 - Changed all Node.js built-in imports to node: specifiers - Updated all .js extensions to .ts in imports - Created mod.ts as Deno entry point - Ready for Phase 3: CLI simplification
		
			
				
	
	
		
			45 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| #!/usr/bin/env -S deno run --allow-all
 | |
| 
 | |
| /**
 | |
|  * NUPST - UPS Shutdown Tool
 | |
|  *
 | |
|  * A command-line tool for monitoring SNMP-enabled UPS devices and
 | |
|  * initiating system shutdown when power conditions are critical.
 | |
|  *
 | |
|  * Required Permissions:
 | |
|  * - --allow-net: SNMP communication with UPS devices
 | |
|  * - --allow-read: Read configuration files (/etc/nupst/config.json)
 | |
|  * - --allow-write: Write configuration files
 | |
|  * - --allow-run: Execute system commands (systemctl, shutdown, git, bash)
 | |
|  * - --allow-sys: Access system information (hostname, OS details)
 | |
|  * - --allow-env: Read environment variables
 | |
|  *
 | |
|  * @module
 | |
|  */
 | |
| 
 | |
| import { NupstCli } from './ts/cli.ts';
 | |
| 
 | |
| /**
 | |
|  * Main entry point for the NUPST application
 | |
|  * Parses command-line arguments and executes the requested command
 | |
|  */
 | |
| async function main(): Promise<void> {
 | |
|   const cli = new NupstCli();
 | |
| 
 | |
|   // Deno.args is already 0-indexed (unlike Node's process.argv which starts at index 2)
 | |
|   // We need to prepend placeholder args to match the existing CLI parser expectations
 | |
|   const args = ['deno', 'mod.ts', ...Deno.args];
 | |
| 
 | |
|   await cli.parseAndExecute(args);
 | |
| }
 | |
| 
 | |
| // Execute main and handle errors
 | |
| if (import.meta.main) {
 | |
|   try {
 | |
|     await main();
 | |
|   } catch (error) {
 | |
|     console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
 | |
|     Deno.exit(1);
 | |
|   }
 | |
| }
 |