Phase 1-2: Migrate to Deno with npm: and node: specifiers
- 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
This commit is contained in:
44
mod.ts
Normal file
44
mod.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user