#!/usr/bin/env node /** * PHP Legacy Refactor AI - CLI Entry Point * Main command-line interface for analyzing and refactoring PHP code */ import { program } from 'commander'; import chalk from 'chalk'; import { analyzeCommand, type AnalyzeOptions } from '../src/commands/analyze.js'; import { testCommand, type TestOptions } from '../src/commands/test.js'; import { docsCommand, type DocsOptions } from '../src/commands/docs.js'; // CLI Configuration program .name('php-refactor') .description('CLI tool to analyze and refactor legacy PHP code using AI') .version('1.0.0'); // Analyze command - detect deprecated functions and suggest improvements program .command('analyze ') .description('Analyze PHP code for deprecations and improvements') .option('-v, --php-version ', 'Target PHP version', '8.3') .option('-o, --output ', 'Output directory for reports', './reports') .option('--model ', 'Ollama model to use', 'llama3') .action((path: string, options: AnalyzeOptions) => analyzeCommand(path, options)); // Test command - generate PHPUnit tests program .command('test ') .description('Generate PHPUnit tests for PHP classes') .option('-o, --output ', 'Output directory for tests', './tests') .option('--model ', 'Ollama model to use', 'llama3') .action((path: string, options: TestOptions) => testCommand(path, options)); // Docs command - generate documentation program .command('docs ') .description('Generate documentation (DocBlock or OpenAPI)') .option('-f, --format ', 'Output format: docblock or openapi', 'docblock') .option('-o, --output ', 'Output file') .option('--model ', 'Ollama model to use', 'llama3') .action((path: string, options: DocsOptions) => docsCommand(path, options)); // Parse arguments program.parse(); // Show help if no command provided if (!process.argv.slice(2).length) { console.log(chalk.cyan('\n🔧 PHP Legacy Refactor AI\n')); program.outputHelp(); }