intelli_shell/utils/mod.rs
1/// Macro to format an error message with theme's error style.
2///
3/// # Examples
4/// ```rust
5/// # use intelli_shell::format_error;
6/// # use intelli_shell::config::Theme;
7/// # let theme = Theme::default();
8/// let msg = format_error!(theme, "Invalid value");
9/// let msg = format_error!(theme, "Invalid value: {}", 42);
10/// ```
11#[macro_export]
12macro_rules! format_error {
13 ($theme:expr, $($arg:tt)*) => {
14 format!("{}{}", $theme.error.apply("[Error] "), format!($($arg)*))
15 }
16}
17
18/// Macro to format an information message with theme's style.
19///
20/// # Examples
21/// ```rust
22/// # use intelli_shell::format_msg;
23/// # use intelli_shell::config::Theme;
24/// # let theme = Theme::default();
25/// let msg = format_msg!(theme, "Succesful operation");
26/// ```
27#[macro_export]
28macro_rules! format_msg {
29 ($theme:expr, $($arg:tt)*) => {
30 format!("{}{}", $theme.accent.apply("-> "), format!($($arg)*))
31 }
32}
33
34/// Declares a `mod` and uses it
35#[macro_export]
36macro_rules! using {
37 ($($v:vis $p:ident),* $(,)?) => {
38 $(
39 mod $p;
40 $v use self::$p::*;
41 )*
42 }
43}
44
45using! {
46 pub process,
47 pub string,
48 pub tags,
49 pub fuzzy,
50 pub variable,
51 pub widget,
52 pub history,
53}