Skip to main content

usage/docs/
mod.rs

1use regex::Regex;
2use std::borrow::Cow;
3use std::sync::LazyLock;
4
5#[cfg(feature = "cli-help")]
6pub mod cli;
7#[cfg(feature = "cli-help")]
8mod layout;
9/// Where a spec's logo goes on a page it shares with the help.
10pub(crate) mod logo;
11#[cfg(feature = "manpage")]
12pub mod manpage;
13#[cfg(feature = "markdown")]
14pub mod markdown;
15#[cfg(feature = "cli-help")]
16pub(crate) mod models;
17
18/// An ANSI control-sequence introducer escape, including the SGR sequences commonly embedded by
19/// `color_print::cstr!`.
20static ANSI_CSI: LazyLock<Regex> =
21    LazyLock::new(|| Regex::new(r"\x1b\[[0-?]*[ -/]*[@-~]").unwrap());
22
23pub(crate) fn strip_ansi(value: &str) -> Cow<'_, str> {
24    ANSI_CSI.replace_all(value, "")
25}