mirror of
https://github.com/dexoron/dcr.git
synced 2026-10-21 11:58:29 +00:00
refactor: created new macro sprintln! and sprint! (src/utils/log.rs) for print stylized text to the console. An additional comment has been created, and access to owo_colors via pub use in src/utils/cli_styles.rs
This commit is contained in:
@@ -15,6 +15,10 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#[allow(unused_imports)]
|
||||
pub use owo_colors::{OwoColorize as Colorize, Style};
|
||||
|
||||
// Сli theme styles
|
||||
#[allow(dead_code)]
|
||||
pub const RESET: &str = "\x1b[0m";
|
||||
|
||||
|
||||
@@ -42,3 +42,28 @@ pub fn init() {
|
||||
})
|
||||
.init();
|
||||
}
|
||||
|
||||
/// Prints message to stdout with the given `Style`. Copy of println! macro
|
||||
#[allow(unused_macros)]
|
||||
macro_rules! sprintln {
|
||||
($style:expr, $($arg:tt)*) => {
|
||||
{
|
||||
use ::owo_colors::OwoColorize as _;
|
||||
println!("{}", format!($($arg)*).style($style));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// Prints message to stdout with the given `Style`. Copy of print! macro
|
||||
#[allow(unused_macros)]
|
||||
macro_rules! sprint {
|
||||
($style:expr, $($arg:tt)*) => {
|
||||
{
|
||||
use ::owo_colors::OwoColorize as _;
|
||||
print!("{}", format!($($arg)*).style($style));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[allow(unused_imports)]
|
||||
pub(crate) use {sprint, sprintln};
|
||||
|
||||
Reference in New Issue
Block a user