alnilam-cli
Version:
Git-native AI career coach that converts multi-year ambitions into weekly execution
99 lines (98 loc) ⢠3.98 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.goalCommand = void 0;
const commander_1 = require("commander");
const api_1 = require("../lib/api");
const goalCommand = new commander_1.Command('goal');
exports.goalCommand = goalCommand;
goalCommand
.description('Manage goals')
.addCommand(new commander_1.Command('add')
.description('Add a new goal')
.requiredOption('--title <title>', 'Goal title')
.requiredOption('--horizon <horizon>', 'Goal horizon (multi-year|annual|quarterly|weekly)')
.option('--description <description>', 'Goal description')
.option('--date <date>', 'Target date (YYYY-MM-DD)')
.option('--json', 'Output as JSON')
.action(async (options) => {
try {
// Validate horizon
const validHorizons = ['multi-year', 'annual', 'quarterly', 'weekly'];
if (!validHorizons.includes(options.horizon)) {
console.error('Error: Invalid horizon. Must be one of:', validHorizons.join(', '));
process.exit(1);
}
const goalData = {
title: options.title,
horizon: options.horizon,
description: options.description,
target_date: options.date,
};
const goal = await (0, api_1.createGoal)(goalData);
if (options.json) {
console.log(JSON.stringify(goal, null, 2));
}
else {
console.log(`ā
Goal "${goal.title}" created successfully`);
console.log(` ID: ${goal.id}`);
console.log(` Horizon: ${goal.horizon}`);
if (goal.target_date) {
console.log(` Target Date: ${goal.target_date}`);
}
}
}
catch (error) {
console.error('Error adding goal:', error instanceof Error ? error.message : error);
process.exit(1);
}
}))
.addCommand(new commander_1.Command('list')
.description('List goals')
.option('--horizon <horizon>', 'Filter by horizon (multi-year|annual|quarterly|weekly)')
.option('--status <status>', 'Filter by status (active|completed|paused|cancelled)', 'active')
.option('--json', 'Output as JSON')
.action(async (options) => {
try {
// Validate horizon if provided
if (options.horizon) {
const validHorizons = ['multi-year', 'annual', 'quarterly', 'weekly'];
if (!validHorizons.includes(options.horizon)) {
console.error('Error: Invalid horizon. Must be one of:', validHorizons.join(', '));
process.exit(1);
}
}
const goals = await (0, api_1.listGoals)({
horizon: options.horizon,
status: options.status,
});
if (options.json) {
console.log(JSON.stringify(goals, null, 2));
}
else {
if (goals.length === 0) {
console.log('No goals found. Use "alnl goal add" to create one.');
}
else {
console.log(`\nš Found ${goals.length} goal(s):\n`);
goals.forEach((goal, index) => {
console.log(`${index + 1}. ${goal.title}`);
console.log(` ID: ${goal.id}`);
console.log(` Horizon: ${goal.horizon}`);
console.log(` Status: ${goal.status}`);
if (goal.target_date) {
console.log(` Target: ${goal.target_date}`);
}
if (goal.description) {
console.log(` Description: ${goal.description}`);
}
console.log(` Created: ${new Date(goal.created_at).toLocaleDateString()}`);
console.log('');
});
}
}
}
catch (error) {
console.error('Error listing goals:', error instanceof Error ? error.message : error);
process.exit(1);
}
}));