task_detail
Single-task detail view composing status, priority, links, tags, and a markdown body section.
const GAP
const GAP: &str = " ";Spacing between label and value columns.
const INDENT
const INDENT: &str = " ";Indentation prefix for detail rows.
struct Component
pub struct Component<'a>Renders the full detail view for a single task, including status, priority, links, tags, and optional body.
| Field | Type | Description |
|---|---|---|
assigned |
Option<&'a str> | Assignee for the assigned row; set only in tests, None hides the row. |
body |
Option<&'a str> | Markdown description, rendered between description and closing rules; None leaves it out. |
id |
&'a str | Full task ID; the header shows its first 8 characters. |
id_prefix_len |
usize | Number of highlighted characters in the header ID and in each link ID; 2 by default. |
links |
Vec<(&'a str, &'a str)> | (relation, id) pairs for the links rows; set only in tests, empty hides the rows. |
phase |
Option<(u32, Option<&'a str>)> | Phase number and optional name for the phase row; set only in tests, None hides the row. |
priority |
Option<u8> | Priority shown as P<n> in the priority row; None hides the row. |
status |
&'a str | Task status, shown as a status badge. |
tags |
&'a [String] | Tag labels for the tags row; the row is hidden when empty. |
title |
&'a str | Task title for the title row. |
Implements Display.
Component::new
pub fn new(id: &'a str, title: &'a str, status: &'a str) -> SelfCreate a detail view for a task with the given id, title, and status.
| Parameter | Type | Description |
|---|---|---|
id |
&'a str | the full task ID |
title |
&'a str | the task title |
status |
&'a str | the task status |
| returns | Self | The view, with only the title and status rows and a 2-character ID prefix. |
Component::body
pub fn body(self, b: Option<&'a str>) -> SelfSets optional markdown body content to render in a description section.
| Parameter | Type | Description |
|---|---|---|
b |
Option<&'a str> | the markdown description, or None for none |
| returns | Self | The view with the body replaced. |
Component::id_prefix_len
pub fn id_prefix_len(self, len: usize) -> SelfSets the highlighted prefix length used for the heading and link IDs.
| Parameter | Type | Description |
|---|---|---|
len |
usize | the prefix length |
| returns | Self | The view with the new prefix length. |
Component::priority
pub fn priority(self, p: Option<u8>) -> SelfSets the task priority level.
| Parameter | Type | Description |
|---|---|---|
p |
Option<u8> | the priority, or None to hide the row |
| returns | Self | The view with the priority replaced. |
Component::body_width
fn body_width(&self) -> usizeWidth available to the markdown body: the terminal width less the indent.
| Parameter | Type | Description |
|---|---|---|
| returns | usize | The width in columns, at least 0. |
Component::label
fn label(&self, text: &str, width: usize) -> LabelBuild a field label in the task.detail.label style.
| Parameter | Type | Description |
|---|---|---|
text |
&str | the label text |
width |
usize | the width to pad it to, from label_width |
| returns | Label | The padded label. |
Component::label_width
fn label_width(&self) -> usizeWidth of the longest label among the rows this task shows, so the values line up.
| Parameter | Type | Description |
|---|---|---|
| returns | usize | The length of that label; at least 6, for status. |
Component::phase_value
fn phase_value(&self, number: u32, name: Option<&str>) -> StringFormat the phase row value.
| Parameter | Type | Description |
|---|---|---|
number |
u32 | the phase number |
name |
Option<&str> | the phase name, if it has one |
| returns | String | The number alone, or the number, a muted · and the name. |
Component::status_badge
fn status_badge(&self) -> StatusBadge<'_>Build the status row value.
| Parameter | Type | Description |
|---|---|---|
| returns | StatusBadge<'_> | A status badge for the task’s status. |