mime-todo-cli/lib/commands/IssuesInSprintCommand.ts
Tiara Rodney 932d4ad420
init
2026-03-15 03:02:41 +01:00

33 lines
1.1 KiB
TypeScript

import type { Argv, ArgumentsCamelCase } from "yargs"
import { CLICommand } from "../cli/CLICommand"
import { parseTodoFile } from "../file"
export class IssuesInSprintCommand extends CLICommand {
readonly name = "issues-in-sprint <name>"
readonly help = "List issues in a sprint"
readonly description = "Find issues whose date range overlaps with a sprint"
addArguments(yargs: Argv): Argv {
return yargs.positional("name", { type: "string", demandOption: true })
}
async execute(args: ArgumentsCamelCase): Promise<number> {
const todo = await parseTodoFile()
const sprint = todo.sprints.find(s => s.name === args.name)
if (!sprint) {
console.error(`Sprint not found: ${args.name}`)
return 1
}
const { start, end } = sprint
for (const issue of todo.issues) {
const ds = issue.dueStart ?? issue.dueEnd
const de = issue.dueEnd ?? issue.dueStart
if (!ds || !de) continue
if (ds <= end && de >= start) {
console.log(`#${issue.id} [${issue.type}] (${issue.status}) ${issue.title}`)
}
}
return 0
}
}