fix(commands): Fix add-tag --from-branch requiring tagName argument

- Made tagName optional when using --from-branch - Added validation for either tagName or --from-branch
- Fixes 'missing required argument' error with --from-branch option
This commit is contained in:
Eyal Toledano
2025-06-13 19:48:54 -04:00
parent 60c0f26f3c
commit d3edd24b5a

View File

@@ -3701,7 +3701,10 @@ Examples:
programInstance
.command('add-tag')
.description('Create a new tag context for organizing tasks')
.argument('<tagName>', 'Name of the new tag to create')
.argument(
'[tagName]',
'Name of the new tag to create (optional when using --from-branch)'
)
.option(
'-f, --file <file>',
'Path to the tasks file',
@@ -3743,6 +3746,19 @@ Examples:
process.exit(1);
}
// Validate that either tagName is provided or --from-branch is used
if (!tagName && !options.fromBranch) {
console.error(
chalk.red(
'Error: Either tagName argument or --from-branch option is required.'
)
);
console.log(chalk.yellow('Usage examples:'));
console.log(chalk.cyan(' task-master add-tag my-tag'));
console.log(chalk.cyan(' task-master add-tag --from-branch'));
process.exit(1);
}
const context = {
projectRoot,
commandName: 'add-tag',