#[allow(clippy::match_like_matches_macro)]
pub(super) const fn enabled(feature: &str) -> bool {
match feature.as_bytes() {
b"roff" => cfg!(feature = "roff"),
b"tui" => cfg!(feature = "tui"),
b"pager" => cfg!(feature = "pager"),
b"mcp" => cfg!(feature = "mcp"),
b"update" => cfg!(feature = "update"),
_ => false,
}
}
pub(super) fn argument_ids<const N: usize>(ids: [&'static str; N]) -> Vec<&'static str> {
ids.into_iter()
.filter(|id| match *id {
"manual" | "man_section" => enabled("roff"),
"mcp" => enabled("mcp"),
"update_docs" | "update_tldr" | "prune_docs" | "dry_run" => enabled("update"),
_ => true,
})
.collect()
}
pub(super) fn usage() -> String {
let mut lines = vec!["mant <SELECTOR> [OPTIONS]"];
if enabled("roff") {
lines.push("mant <MAN_SECTION> <NAME> [OPTIONS]");
}
lines.extend([
"mant --document <SELECTOR>... [--follow-links] [OPTIONS]",
"mant --input <PATH|-> [--input-format <FORMAT>] [OPTIONS]",
"mant --list [FILTERS]",
"mant --find <PATTERN> [FILTERS]",
"mant --request-json [--format <FORMAT>] [--compact]",
"mant --doctor [--format <text|json>] [--compact]",
"mant --schema <CONTRACT> [--compact]",
]);
if enabled("update") {
lines.extend([
"mant --update-docs [--compact]",
"mant --prune-docs [--dry-run] [--compact]",
"mant --update-tldr [--compact]",
]);
}
lines.push("mant --protocol-version [--compact]");
if enabled("mcp") {
lines.push("mant --mcp");
}
lines.join("\n ")
}
#[cfg(test)]
mod tests;