takt/src/infra/task/display.ts
2026-02-02 17:11:42 +09:00

68 lines
2.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Task display utilities
*
* UI/表示に関する関数を分離
*/
import chalk from 'chalk';
import { header, info, divider } from '../../shared/ui/index.js';
import type { TaskRunner } from './runner.js';
/**
* タスク一覧を表示
*/
export function showTaskList(runner: TaskRunner): void {
const tasks = runner.listTasks();
console.log();
divider('=', 60);
header('TAKT タスク一覧');
divider('=', 60);
console.log(chalk.gray(`タスクディレクトリ: ${runner.getTasksDir()}`));
divider('-', 60);
if (tasks.length === 0) {
console.log();
info('実行待ちのタスクはありません。');
console.log(chalk.gray(`\n${runner.getTasksDir()}/ にタスクファイル(.yaml/.mdを配置してください。`));
console.log(chalk.gray(`または takt add でタスクを追加できます。`));
return;
}
console.log(chalk.green(`\n${tasks.length} 個のタスクがあります:\n`));
for (let i = 0; i < tasks.length; i++) {
const task = tasks[i];
if (task) {
// タスク内容の最初の行を取得
const firstLine = task.content.trim().split('\n')[0]?.slice(0, 60) ?? '';
console.log(chalk.cyan.bold(` [${i + 1}] ${task.name}`));
console.log(chalk.gray(` ${firstLine}...`));
// Show worktree/branch info for YAML tasks
if (task.data) {
const extras: string[] = [];
if (task.data.worktree) {
extras.push(`worktree: ${typeof task.data.worktree === 'string' ? task.data.worktree : 'auto'}`);
}
if (task.data.branch) {
extras.push(`branch: ${task.data.branch}`);
}
if (task.data.workflow) {
extras.push(`workflow: ${task.data.workflow}`);
}
if (extras.length > 0) {
console.log(chalk.dim(` [${extras.join(', ')}]`));
}
}
}
}
console.log();
divider('=', 60);
console.log(chalk.yellow.bold('使用方法:'));
console.log(chalk.gray(' /add-task タスクを追加'));
console.log(chalk.gray(' /task run 次のタスクを実行'));
console.log(chalk.gray(' /task run <name> 指定したタスクを実行'));
}