revit-cli
Version:
A scalable CLI tool for Revit communication and data manipulation
98 lines • 3.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CLIOrchestrator = void 0;
const commander_1 = require("commander");
const welcome_screen_1 = require("../ui/welcome-screen");
const initializer_1 = require("../cli/initializer");
const command_registry_1 = require("../cli/command-registry");
const core_commands_1 = require("../commands/core-commands");
const room_commands_1 = require("../commands/room-commands");
const wall_commands_1 = require("../commands/wall-commands");
/**
* Main CLI orchestrator that coordinates all components
*/
class CLIOrchestrator {
constructor() {
this.state = null;
this.program = new commander_1.Command();
this.setupProgram();
}
/**
* Setup the base program configuration
*/
setupProgram() {
this.program
.name('revit-cli')
.description('CLI for communicating with Autodesk Revit')
.version('1.0.0');
}
/**
* Get or initialize CLI state
*/
async getState() {
if (!this.state) {
this.state = await (0, initializer_1.initializeCLI)();
(0, initializer_1.setupErrorHandlers)(this.state.logger);
}
return this.state;
}
/**
* Register all commands (core and plugin-based)
*/
async registerCommands() {
const state = await this.getState();
// Register core commands
(0, core_commands_1.registerCoreCommands)(this.program, () => this.getState());
// Register room commands
(0, room_commands_1.registerRoomCommands)(this.program, () => this.getState());
// Register wall commands
(0, wall_commands_1.registerWallCommands)(this.program, () => this.getState());
// Register plugin commands
(0, command_registry_1.registerPluginCommands)(this.program, state.pluginManager, state.toolContext, state.logger);
}
/**
* Display appropriate welcome screen based on mode
*/
async displayWelcome() {
if (process.argv.length <= 2) {
// Interactive mode - show welcome screen with prompt
await (0, welcome_screen_1.displayWelcomeScreen)();
}
else {
// Command mode - show header only
(0, welcome_screen_1.displayHeader)();
}
}
/**
* Execute the CLI with proper initialization and error handling
*/
async execute() {
try {
// Display welcome screen
await this.displayWelcome();
// Register all commands
await this.registerCommands();
// Parse and execute
if (process.argv.length <= 2) {
// No arguments provided, show help
this.program.help();
}
else {
await this.program.parseAsync(process.argv);
}
}
catch (error) {
const state = await this.getState();
state.logger.error('CLI execution failed:', error);
process.exit(1);
}
}
/**
* Get the commander program instance (for testing)
*/
getProgram() {
return this.program;
}
}
exports.CLIOrchestrator = CLIOrchestrator;
//# sourceMappingURL=orchestrator.js.map