feat(01-02): create CLI with commander
- Add createCli() function with commander configuration - Register placeholder commands: status, agent, task - Add graceful error handling for uncaught exceptions - Read version from package.json via index.ts export
This commit is contained in:
@@ -1,8 +1,26 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Codewalk District CLI Entry Point
|
||||
*
|
||||
* Users can install globally via:
|
||||
* - npm link (during development)
|
||||
* - npm i -g codewalk-district (for release)
|
||||
*/
|
||||
|
||||
import { VERSION } from '../index.js';
|
||||
import { createCli } from '../cli/index.js';
|
||||
|
||||
console.log(`cw cli v${VERSION}`);
|
||||
const program = createCli();
|
||||
|
||||
// Handle uncaught errors gracefully
|
||||
process.on('uncaughtException', (error) => {
|
||||
console.error('Fatal error:', error.message);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
process.on('unhandledRejection', (reason) => {
|
||||
console.error('Unhandled promise rejection:', reason);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
// Parse command line arguments
|
||||
program.parse(process.argv);
|
||||
|
||||
46
src/cli/index.ts
Normal file
46
src/cli/index.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Codewalk District CLI
|
||||
*
|
||||
* Commander-based CLI with help system and version display.
|
||||
*/
|
||||
|
||||
import { Command } from 'commander';
|
||||
import { VERSION } from '../index.js';
|
||||
|
||||
/**
|
||||
* Creates and configures the CLI program.
|
||||
*
|
||||
* @returns Configured Commander program ready for parsing
|
||||
*/
|
||||
export function createCli(): Command {
|
||||
const program = new Command();
|
||||
|
||||
program
|
||||
.name('cw')
|
||||
.description('Multi-agent workspace for orchestrating multiple Claude Code agents')
|
||||
.version(VERSION, '-v, --version', 'Display version number');
|
||||
|
||||
// Placeholder commands - will be implemented in later phases
|
||||
program
|
||||
.command('status')
|
||||
.description('Show workspace status')
|
||||
.action(() => {
|
||||
console.log('cw status: not implemented');
|
||||
});
|
||||
|
||||
program
|
||||
.command('agent')
|
||||
.description('Manage agents')
|
||||
.action(() => {
|
||||
console.log('cw agent: not implemented');
|
||||
});
|
||||
|
||||
program
|
||||
.command('task')
|
||||
.description('Manage tasks')
|
||||
.action(() => {
|
||||
console.log('cw task: not implemented');
|
||||
});
|
||||
|
||||
return program;
|
||||
}
|
||||
Reference in New Issue
Block a user