Skip to content

Commit a727ccb

Browse files
author
Umutcan ÖNER
committed
feat: add version flag to CLI tool
- Add support for --version and -v flags - Read version dynamically from package.json - Update help text to include new options
1 parent dc24ad8 commit a727ccb

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

scripts/index.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,53 @@
44
* AICD CLI - Command Line Interface for AI-powered continuous deployment
55
*/
66

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}`);
820
console.log('AI-powered continuous deployment platform');
921

1022
// Simple CLI implementation for testing the release workflow
1123
const args = process.argv.slice(2);
1224

25+
// Check for version flags first
26+
if (args.includes('--version') || args.includes('-v')) {
27+
console.log(version);
28+
process.exit(0);
29+
}
30+
1331
if (args.length === 0) {
14-
console.log('\nUsage: aicd [command]');
32+
console.log('\nUsage: aicd [command] [options]');
1533
console.log('\nCommands:');
1634
console.log(' version Show version information');
1735
console.log(' help Show this help message');
36+
console.log('\nOptions:');
37+
console.log(' --version, -v Display version number');
1838
process.exit(0);
1939
}
2040

2141
const command = args[0];
2242

2343
switch (command) {
2444
case 'version':
25-
console.log('\nVersion: 0.1.0');
45+
console.log(`\nVersion: ${version}`);
2646
break;
2747
case 'help':
28-
console.log('\nUsage: aicd [command]');
48+
console.log('\nUsage: aicd [command] [options]');
2949
console.log('\nCommands:');
3050
console.log(' version Show version information');
3151
console.log(' help Show this help message');
52+
console.log('\nOptions:');
53+
console.log(' --version, -v Display version number');
3254
break;
3355
default:
3456
console.error(`Unknown command: ${command}`);

0 commit comments

Comments
 (0)