Skip to main content

apm/cmd/
list.rs

1use anyhow::Result;
2use apm_core::config::resolve_identity;
3use std::path::Path;
4use crate::ctx::CmdContext;
5
6pub fn run(root: &Path, state_filter: Option<String>, unassigned: bool, all: bool, actionable_filter: Option<String>, no_aggressive: bool, mine: bool, author: Option<String>, owner: Option<String>) -> Result<()> {
7    let ctx = CmdContext::load(root, no_aggressive)?;
8
9    let mine_user: Option<String> = if mine {
10        Some(resolve_identity(root))
11    } else {
12        None
13    };
14    let author_filter = if mine { None } else { author };
15
16    let filtered = apm_core::ticket::list_filtered(
17        &ctx.tickets,
18        &ctx.config,
19        state_filter.as_deref(),
20        unassigned,
21        all,
22        actionable_filter.as_deref(),
23        author_filter.as_deref(),
24        owner.as_deref(),
25        mine_user.as_deref(),
26    );
27
28    for t in filtered {
29        let fm = &t.frontmatter;
30        let owner = fm.owner.as_deref().unwrap_or("-");
31        println!("{:<8} [{:<12}] {:<16} {}", fm.id, fm.state, owner, fm.title);
32    }
33    Ok(())
34}