oma_console/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! # oma-console
//!
//! `oma-console` is a utility crate that provides console functionalities for *oma*
//!
//! It offers modules for printing stylized messages, managing pagers, displaying progress bars, and handling terminal writing utilities.
//!
//! ## Features
//!
//! - **Print**: Stylized message printer with support for prefixes and automatic line wrapping.
//! - **Pager**: Terminal pager with scrolling and searching capabilities.
//!
//! ## Modules
//!
//! - `pager`: Implements a terminal pager with the `crossterm` and `ratatui` crates.
//! - `pb`: Implements numerous styles of progress bars with the `indicatif` crate.
//! - `writer`: Implements a formatted message writer to the terminal.
//! - `print`: Implements a formatted message logger with support for different logging levels (normal, debug, error, etc.).
//!

#[cfg(feature = "pager")]
pub mod pager;

#[cfg(feature = "progress_bar_style")]
pub mod pb;

#[cfg(feature = "print")]
pub mod writer;

#[cfg(feature = "print")]
pub mod print;

#[cfg(feature = "print")]
pub use print::OmaLayer;

#[cfg(feature = "print")]
pub use console;

#[cfg(feature = "progress_bar_style")]
pub use indicatif;

#[cfg(feature = "print")]
use writer::Writer;

#[cfg(feature = "print")]
pub static WRITER: std::sync::LazyLock<Writer> = std::sync::LazyLock::new(writer::Writer::default);

#[cfg(feature = "print")]
pub fn is_terminal() -> bool {
    WRITER.is_terminal()
}