|
4 | 4 | * AICD CLI - Command Line Interface for AI-powered continuous deployment
|
5 | 5 | */
|
6 | 6 |
|
7 |
| -console.log('AICD CLI v0.1.0'); |
| 7 | +import { readFileSync } from 'node:fs'; |
| 8 | +import { join, dirname } from 'node:path'; |
| 9 | +import { fileURLToPath } from 'node:url'; |
| 10 | + |
| 11 | +// Get the directory of this script |
| 12 | +const __dirname = dirname(fileURLToPath(import.meta.url)); |
| 13 | + |
| 14 | +// Read version from package.json |
| 15 | +const packageJsonPath = join(__dirname, '..', 'package.json'); |
| 16 | +const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8')); |
| 17 | +const version = packageJson.version; |
| 18 | + |
| 19 | +console.log(`AICD CLI v${version}`); |
8 | 20 | console.log('AI-powered continuous deployment platform');
|
9 | 21 |
|
10 | 22 | // Simple CLI implementation for testing the release workflow
|
11 | 23 | const args = process.argv.slice(2);
|
12 | 24 |
|
| 25 | +// Check for version flags first |
| 26 | +if (args.includes('--version') || args.includes('-v')) { |
| 27 | + console.log(version); |
| 28 | + process.exit(0); |
| 29 | +} |
| 30 | + |
13 | 31 | if (args.length === 0) {
|
14 |
| - console.log('\nUsage: aicd [command]'); |
| 32 | + console.log('\nUsage: aicd [command] [options]'); |
15 | 33 | console.log('\nCommands:');
|
16 | 34 | console.log(' version Show version information');
|
17 | 35 | console.log(' help Show this help message');
|
| 36 | + console.log('\nOptions:'); |
| 37 | + console.log(' --version, -v Display version number'); |
18 | 38 | process.exit(0);
|
19 | 39 | }
|
20 | 40 |
|
21 | 41 | const command = args[0];
|
22 | 42 |
|
23 | 43 | switch (command) {
|
24 | 44 | case 'version':
|
25 |
| - console.log('\nVersion: 0.1.0'); |
| 45 | + console.log(`\nVersion: ${version}`); |
26 | 46 | break;
|
27 | 47 | case 'help':
|
28 |
| - console.log('\nUsage: aicd [command]'); |
| 48 | + console.log('\nUsage: aicd [command] [options]'); |
29 | 49 | console.log('\nCommands:');
|
30 | 50 | console.log(' version Show version information');
|
31 | 51 | console.log(' help Show this help message');
|
| 52 | + console.log('\nOptions:'); |
| 53 | + console.log(' --version, -v Display version number'); |
32 | 54 | break;
|
33 | 55 | default:
|
34 | 56 | console.error(`Unknown command: ${command}`);
|
|
0 commit comments