index.ts
1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env node
/**
* CLI Entry Point for Coderio.
* This file handles command registration, argument parsing, and global error handling for the CLI.
*/
// Save the user's current working directory before any operations
process.env.CODERIO_CLI_USER_CWD = process.cwd();
import { Command } from 'commander';
import { registerCommands } from './init';
import { logger } from '../utils/logger';
import { registerD2PCommand } from './d2p';
import { registerD2CCommand } from './d2c';
import { registerImagesCommand } from './images';
import { registerP2CCommand } from './p2c';
import { registerValidateCommand } from './val';
import { registerServeCommand } from './serve';
async function main(argv: string[]): Promise<void> {
const program = new Command();
// Register all commands
registerCommands(program);
registerD2CCommand(program);
registerD2PCommand(program);
registerP2CCommand(program);
registerImagesCommand(program);
registerValidateCommand(program);
registerServeCommand(program);
if (argv.length <= 2) {
program.help({ error: false });
return;
}
// Parse arguments and execute actions
await program.parseAsync(argv);
}
main(process.argv).catch(err => {
const error = err as Error;
logger.printErrorLog(`${error.message || String(error)}`);
process.exit(1);
});