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#[cfg(feature = "manpage")]
10pub mod manpage;
11#[cfg(feature = "markdown")]
12pub mod markdown;
13#[cfg(feature = "cli-help")]
14pub(crate) mod models;
15
16/// An ANSI control-sequence introducer escape, including the SGR sequences commonly embedded by
17/// `color_print::cstr!`.
18static ANSI_CSI: LazyLock<Regex> =
19    LazyLock::new(|| Regex::new(r"\x1b\[[0-?]*[ -/]*[@-~]").unwrap());
20
21pub(crate) fn strip_ansi(value: &str) -> Cow<'_, str> {
22    ANSI_CSI.replace_all(value, "")
23}