@fromsvenwithlove/devops-issues-cli
Version:
AI-powered CLI tool and library for Azure DevOps work item management with Claude agents
54 lines (47 loc) • 1.47 kB
JavaScript
import chalk from 'chalk';
import { getConfig, ConfigError } from '../config/index.js';
import { AzureDevOpsClient } from '../api/azure-client.js';
import {
formatWorkItemsAsTable,
formatWorkItemsAsJson,
formatWorkItemsMinimal,
formatSummary
} from '../utils/formatter.js';
export default async function listCommand(options) {
try {
// Get configuration
const config = getConfig();
// Create and connect client
const client = new AzureDevOpsClient(config);
await client.connect();
// Fetch work items
const workItems = await client.getAssignedWorkItems({
state: options.state,
type: options.type,
limit: options.limit
});
if (workItems.length === 0) {
console.log(chalk.green('✅ No work items assigned to you'));
return;
}
// Format and display results
console.log(''); // Empty line for better formatting
if (options.json) {
console.log(formatWorkItemsAsJson(workItems));
} else if (options.minimal) {
console.log(formatWorkItemsMinimal(workItems));
} else {
console.log(formatWorkItemsAsTable(workItems));
console.log(formatSummary(workItems));
}
} catch (error) {
if (error instanceof ConfigError) {
console.error(chalk.red('Configuration Error:'));
console.error(error.message);
process.exit(1);
} else {
console.error(chalk.red('Error:'), error.message);
process.exit(3);
}
}
}