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:
alex-xr555
2026-09-24 00:28:50 +03:00
parent 2f4cde9177
commit e9d09eacaf
2 changed files with 29 additions and 0 deletions

View File

@@ -15,6 +15,10 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // 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)] #[allow(dead_code)]
pub const RESET: &str = "\x1b[0m"; pub const RESET: &str = "\x1b[0m";

View File

@@ -42,3 +42,28 @@ pub fn init() {
}) })
.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};