(07ac4e1) Filter campaign ls by state, and lay its listing out as a table, and bump to 0.33.6
campaign ls printed every campaign and offered no way to narrow it, and the row was assembled by hand, so a long title pushed the standing out of line with the row above it and the created date the file already carries was not shown at all. --state takes open, done or empty and matches against Standing::state(), so the derived value keeps one definition: a campaign reads [open] in the listing if and only if --state open lists it. --state rather than --status, which names one of the five ticket statuses everywhere else and would invite --state backlog here. empty is the third value because an empty campaign derives None deliberately, and a filter that could not reach those would leave what has been filed and forgotten answerable only by reading the whole listing. A filter that matches nothing names the value back, since a silent listing reads as the other empty case. The filter reaches --ids as well, the way ls --ids keeps its own, and is the only thing that makes that path count members: an unfiltered completion is as cheap as it was. The columns are measured on the raw values and padded before anything is painted, the rule metadata_cells follows. The codename is measured with the title rather than given a column of its own: a campaign filed without one spends nothing on it, so a column for it would be one most rows pad into and some leave empty, and what a reader lines up is where a name ends and its progress begins. A flag's possible values now come off the command that holds the flag, so campaign ls --state reaches ls's own arguments rather than campaign's. The prompt offered nothing there while fish offered the three values, which made a liar of the rule that a ValueEnum added anywhere is typeable on the board the day it is added. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
3e732535f8
commit
634a1f44c4
+55
-1
@@ -238,6 +238,13 @@ pub fn members(worklane_dir: &Path, uuid: &str) -> Result<Vec<(&'static str, Vec
|
||||
Ok(grouped)
|
||||
}
|
||||
|
||||
/// A campaign with work outstanding, beside [`DONE`] for one with none left.
|
||||
///
|
||||
/// Not a [`Status`]: no ticket is ever in it and no directory is named for it. It is the
|
||||
/// campaign's own two-word vocabulary, and it is a const because the listing prints it,
|
||||
/// [`Standing::state`] derives it and [`CampaignState`] filters on it.
|
||||
pub const OPEN: &str = "open";
|
||||
|
||||
/// How far a campaign has got: members done against members held.
|
||||
///
|
||||
/// `Copy` because the board carries one on every `CampaignRow`, settled at reload: two
|
||||
@@ -282,7 +289,54 @@ impl Standing {
|
||||
match (self.total, self.done == self.total) {
|
||||
(0, _) => None,
|
||||
(_, true) => Some(DONE),
|
||||
(_, false) => Some("open"),
|
||||
(_, false) => Some(OPEN),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The state a campaign is in, as `campaign ls --state` accepts it.
|
||||
///
|
||||
/// A `ValueEnum` for the reason [`Status`] is one: an unknown value is clap's to refuse
|
||||
/// at parse time with the three listed, no handler has to check, and every shell that
|
||||
/// completes possible values gets them for free.
|
||||
///
|
||||
/// `--state` and not `--status`, which names one of the five ticket statuses everywhere
|
||||
/// else in the tool. A campaign sits in no status directory, and borrowing the word for
|
||||
/// a different vocabulary is how a reader comes to type `--status backlog` here.
|
||||
///
|
||||
/// `Empty` is the third value because [`Standing::state`] answers `None` for a campaign
|
||||
/// nothing has been filed against, deliberately, and a filter that could not reach those
|
||||
/// would leave the one question a grooming sweep asks — what has been filed and forgotten
|
||||
/// — answerable only by reading the whole listing.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, clap::ValueEnum)]
|
||||
pub enum CampaignState {
|
||||
/// Holds members, and at least one of them is not finished
|
||||
Open,
|
||||
/// Holds members, and every one of them is done or discarded
|
||||
Done,
|
||||
/// Holds no members at all, so it is neither open nor done
|
||||
Empty,
|
||||
}
|
||||
|
||||
impl CampaignState {
|
||||
/// The value as it is typed, which is what a message naming the filter repeats back.
|
||||
pub fn as_str(self) -> &'static str {
|
||||
match self {
|
||||
Self::Open => OPEN,
|
||||
Self::Done => DONE,
|
||||
Self::Empty => "empty",
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether a campaign in this standing is the one the filter asked for.
|
||||
///
|
||||
/// Matched against [`Standing::state`] rather than against the counters, so the
|
||||
/// derived value has one definition: a campaign reads `[open]` in the listing if and
|
||||
/// only if `--state open` lists it.
|
||||
pub fn holds(self, standing: &Standing) -> bool {
|
||||
match self {
|
||||
Self::Empty => standing.state().is_none(),
|
||||
wanted => standing.state() == Some(wanted.as_str()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user