revit-cli
Version:
A scalable CLI tool for Revit communication and data manipulation
100 lines • 3.89 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.registerCoreCommands = registerCoreCommands;
const chalk_1 = __importDefault(require("chalk"));
/**
* Register core CLI commands
*/
function registerCoreCommands(program, getState) {
// List command
program
.command('list')
.description('List all available tools')
.action(async () => {
try {
const { pluginManager } = await getState();
const tools = pluginManager.getRegisteredTools();
console.log(chalk_1.default.blue('\nAvailable Tools:'));
const categories = {};
for (const tool of tools) {
const category = tool.category || 'general';
if (!categories[category]) {
categories[category] = [];
}
categories[category].push({ name: tool.name, description: tool.description });
}
Object.entries(categories).forEach(([category, categoryTools]) => {
console.log(`\n${chalk_1.default.yellow(category.toUpperCase())}:`);
categoryTools.forEach(tool => {
console.log(` ${chalk_1.default.green(tool.name)} - ${tool.description}`);
});
});
console.log(`\nTotal: ${chalk_1.default.cyan(tools.length)} tools available\n`);
}
catch (error) {
const { logger } = await getState();
logger.error('Failed to list tools:', error);
process.exit(1);
}
});
// Config command
program
.command('config')
.description('Manage configuration')
.option('-s, --show', 'Show current configuration')
.option('-e, --edit', 'Edit configuration interactively')
.option('-r, --reset', 'Reset to default configuration')
.action(async (options) => {
try {
const { configManager, logger } = await getState();
if (options.show) {
const config = configManager.getConfig();
console.log(chalk_1.default.blue('\nCurrent Configuration:'));
console.log(JSON.stringify(config, null, 2));
}
else if (options.edit) {
await configManager.editInteractive();
logger.success('Configuration updated successfully');
}
else if (options.reset) {
await configManager.resetToDefaults();
logger.success('Configuration reset to defaults');
}
else {
console.log('Use --show, --edit, or --reset options');
}
}
catch (error) {
const { logger } = await getState();
logger.error('Configuration command failed:', error);
process.exit(1);
}
});
// Test connection command
program
.command('test-connection')
.description('Test connection to Revit API')
.action(async () => {
try {
const { revitConnector, logger } = await getState();
logger.info('Testing Revit connection...');
const isConnected = await revitConnector.testConnection();
if (isConnected) {
logger.success('✅ Successfully connected to Revit API');
}
else {
logger.error('❌ Failed to connect to Revit API');
process.exit(1);
}
}
catch (error) {
const { logger } = await getState();
logger.error('Connection test failed:', error);
process.exit(1);
}
});
}
//# sourceMappingURL=core-commands.js.map