42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
import type { Argv, ArgumentsCamelCase } from "yargs"
|
|
import { CLICommand } from "../cli/CLICommand"
|
|
import { parseTodoFile } from "../file"
|
|
|
|
export class IssueShowCommand extends CLICommand {
|
|
readonly name = "show <id>"
|
|
readonly help = "Show details for a single issue"
|
|
readonly description = "Print all fields for one issue"
|
|
|
|
addArguments(yargs: Argv): Argv {
|
|
return yargs.positional("id", { type: "number", demandOption: true })
|
|
}
|
|
|
|
async execute(args: ArgumentsCamelCase): Promise<number> {
|
|
const todo = await parseTodoFile()
|
|
const issue = todo.issues.find(i => i.id === args.id)
|
|
if (!issue) {
|
|
console.error(`Issue #${args.id} not found`)
|
|
return 1
|
|
}
|
|
|
|
console.log(`ID: ${issue.id}`)
|
|
console.log(`Type: ${issue.type}`)
|
|
console.log(`Title: ${issue.title}`)
|
|
console.log(`Status: ${issue.status}`)
|
|
console.log(`Priority: ${issue.priority}`)
|
|
console.log(`Created: ${issue.created}`)
|
|
if (issue.module) console.log(`Module: ${issue.module}`)
|
|
if (issue.dueStart) console.log(`DueStart: ${issue.dueStart}`)
|
|
if (issue.dueEnd) console.log(`DueEnd: ${issue.dueEnd}`)
|
|
const rels = Object.entries(issue.relationships)
|
|
.map(([k, v]) => `${k}:${(v as number[]).join(" ")}`)
|
|
.join(", ")
|
|
console.log(`Relationships: ${rels}`)
|
|
console.log(`Description: ${issue.description}`)
|
|
if (issue.body) {
|
|
console.log()
|
|
console.log(issue.body)
|
|
}
|
|
return 0
|
|
}
|
|
}
|