fix: error handling of task status settings

This commit is contained in:
shenysun
2025-05-15 21:18:30 +08:00
parent 09d839fff5
commit 97bf01a0ac
8 changed files with 91 additions and 3 deletions

View File

@@ -73,6 +73,10 @@ import {
getApiKeyStatusReport
} from './task-manager/models.js';
import { findProjectRoot } from './utils.js';
import {
isValidTaskStatus,
TASK_STATUS_OPTIONS
} from '../../src/shared/task-status.js';
/**
* Runs the interactive setup process for model configuration.
@@ -1038,7 +1042,7 @@ function registerCommands(programInstance) {
)
.option(
'-s, --status <status>',
'New status (todo, in-progress, review, done)'
`New status (one of: ${TASK_STATUS_OPTIONS.join(', ')})`
)
.option('-f, --file <file>', 'Path to the tasks file', 'tasks/tasks.json')
.action(async (options) => {
@@ -1051,6 +1055,16 @@ function registerCommands(programInstance) {
process.exit(1);
}
if (!isValidTaskStatus(status)) {
console.error(
chalk.red(
`Error: Invalid status value: ${status}. Use one of: ${TASK_STATUS_OPTIONS.join(', ')}`
)
);
process.exit(1);
}
console.log(
chalk.blue(`Setting status of task(s) ${taskId} to: ${status}`)
);