@aura-ai/cli
Version:
A Go-to-Market CLI tool for analyzing product positioning and market strategy
51 lines (50 loc) • 1.95 kB
JavaScript
import { program } from 'commander';
import React from 'react';
import { render } from 'ink';
import { readFile } from 'fs/promises';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
// Get package.json for version
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const packageJson = JSON.parse(await readFile(join(__dirname, '..', 'package.json'), 'utf-8'));
// 4.2 Configure Commander.js
program
.name('aura')
.description('AI-powered GTM analysis tool for developers')
.version(packageJson.version)
.option('--debug', 'Enable debug mode to log API calls');
// 4.3 Define init command
program
.command('init')
.description('Analyze a project repository and generate GTM insights')
.option('-p, --path <path>', 'Path to the repository (defaults to current directory)')
.action(async (options, command) => {
// Get global debug option from parent program
const debugMode = command.parent?.opts().debug || false;
// Dynamically import to avoid circular dependencies
const { default: InitCommand } = await import('./commands/init.js');
render(React.createElement(InitCommand, { path: options.path, debug: debugMode }));
});
// 4.5 Add help information
program
.addHelpText('after', `
Examples:
$ aura init Analyze the current directory
$ aura init --path ../project Analyze a specific directory
$ aura --debug init Analyze with debug logging enabled
$ aura Enter interactive mode
`);
// Parse arguments
const args = process.argv.slice(2);
// 4.4 Handle no arguments - enter interactive mode
if (args.length === 0) {
// Enter interactive mode
const { default: App } = await import('./app.js');
render(React.createElement(App, null));
}
else {
// 4.6 Parse commands and handle unknown commands
program.parse(process.argv);
}