update
This commit is contained in:
68
ts/cli/index.ts
Normal file
68
ts/cli/index.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import * as plugins from '../plugins.js';
|
||||
import * as paths from '../paths.js';
|
||||
import { Logger, LogLevel } from '../utils.errorhandler.js';
|
||||
|
||||
// Import command registration functions
|
||||
import { registerDefaultCommand } from './commands/default.js';
|
||||
import { registerStartCommand } from './commands/process/start.js';
|
||||
import { registerStopCommand } from './commands/process/stop.js';
|
||||
import { registerRestartCommand } from './commands/process/restart.js';
|
||||
import { registerDeleteCommand } from './commands/process/delete.js';
|
||||
import { registerListCommand } from './commands/process/list.js';
|
||||
import { registerDescribeCommand } from './commands/process/describe.js';
|
||||
import { registerLogsCommand } from './commands/process/logs.js';
|
||||
import { registerStartAllCommand } from './commands/batch/start-all.js';
|
||||
import { registerStopAllCommand } from './commands/batch/stop-all.js';
|
||||
import { registerRestartAllCommand } from './commands/batch/restart-all.js';
|
||||
import { registerDaemonCommand } from './commands/daemon/index.js';
|
||||
import { registerEnableCommand } from './commands/service/enable.js';
|
||||
import { registerDisableCommand } from './commands/service/disable.js';
|
||||
|
||||
// Export types for external use
|
||||
export type { CliArguments } from './types.js';
|
||||
|
||||
/**
|
||||
* Main CLI entry point
|
||||
*/
|
||||
export const run = async (): Promise<void> => {
|
||||
const cliLogger = new Logger('CLI');
|
||||
const tspmProjectinfo = new plugins.projectinfo.ProjectInfo(paths.packageDir);
|
||||
|
||||
// Check if debug mode is enabled
|
||||
const debugMode = process.env.TSPM_DEBUG === 'true';
|
||||
if (debugMode) {
|
||||
cliLogger.setLevel(LogLevel.DEBUG);
|
||||
cliLogger.debug('Debug mode enabled');
|
||||
}
|
||||
|
||||
const smartcliInstance = new plugins.smartcli.Smartcli();
|
||||
smartcliInstance.addVersion(tspmProjectinfo.npm.version);
|
||||
|
||||
// Register all commands
|
||||
// Default command (help + list)
|
||||
registerDefaultCommand(smartcliInstance);
|
||||
|
||||
// Process commands
|
||||
registerStartCommand(smartcliInstance);
|
||||
registerStopCommand(smartcliInstance);
|
||||
registerRestartCommand(smartcliInstance);
|
||||
registerDeleteCommand(smartcliInstance);
|
||||
registerListCommand(smartcliInstance);
|
||||
registerDescribeCommand(smartcliInstance);
|
||||
registerLogsCommand(smartcliInstance);
|
||||
|
||||
// Batch commands
|
||||
registerStartAllCommand(smartcliInstance);
|
||||
registerStopAllCommand(smartcliInstance);
|
||||
registerRestartAllCommand(smartcliInstance);
|
||||
|
||||
// Daemon commands
|
||||
registerDaemonCommand(smartcliInstance);
|
||||
|
||||
// Service commands
|
||||
registerEnableCommand(smartcliInstance);
|
||||
registerDisableCommand(smartcliInstance);
|
||||
|
||||
// Start parsing commands
|
||||
smartcliInstance.startParse();
|
||||
};
|
Reference in New Issue
Block a user