term_detect/
lib.rs

1#[cfg(feature = "cache")]
2pub mod cache;
3#[cfg(feature = "cmdtrait")]
4mod cmdtrait;
5pub mod desktops;
6pub mod detector;
7mod error;
8mod structs;
9pub(crate) mod xdg;
10
11#[cfg(feature = "cache")]
12use cache::*;
13#[cfg(feature = "cmdtrait")]
14pub use cmdtrait::*;
15use detector::*;
16pub use error::DetectionError;
17pub use structs::Terminal;
18
19/// Gets the default terminal  
20///
21/// If the `cache` feature is enabled, the result is cached  
22/// The cache can be reset with `cache::cache_clear`
23pub fn get_terminal() -> Result<Terminal, DetectionError> {
24    #[cfg(feature = "cache")]
25    if let Ok(term) = cache_get() {
26        return Ok(term);
27    }
28    let term = detect_terminal();
29    #[cfg(feature = "cache")]
30    if let Ok(term) = term.as_ref() {
31        let _ = cache_set(term.clone());
32    };
33    term
34}
35
36#[doc = include_str!("../README.md")]
37#[cfg(doctest)]
38pub struct ReadmeDoctests;