aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart-core/src/console.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/mozart-core/src/console.rs')
-rw-r--r--crates/mozart-core/src/console.rs60
1 files changed, 60 insertions, 0 deletions
diff --git a/crates/mozart-core/src/console.rs b/crates/mozart-core/src/console.rs
index fb7c9b9..734074e 100644
--- a/crates/mozart-core/src/console.rs
+++ b/crates/mozart-core/src/console.rs
@@ -259,6 +259,66 @@ impl Console {
}
}
+/// Writes a message to the output.
+///
+/// ref: \Composer\IO\IOInterface::write()
+#[macro_export]
+macro_rules! console_writeln {
+ ($console:expr, $msg:expr $(,)?) => {
+ $crate::console_writeln!($console, $msg, $crate::console::Verbosity::Normal)
+ };
+ ($console:expr, $msg:expr, $verbosity:expr $(,)?) => {
+ if ($console).verbosity >= $verbosity {
+ println!("{}", $msg);
+ }
+ };
+}
+
+/// Writes a message to the output without newline.
+///
+/// ref: \Composer\IO\IOInterface::write()
+#[macro_export]
+macro_rules! console_write {
+ ($console:expr, $msg:expr $(,)?) => {
+ $crate::console_write!($console, $msg, $crate::console::Verbosity::Normal)
+ };
+ ($console:expr, $msg:expr, $verbosity:expr $(,)?) => {
+ if ($console).verbosity >= $verbosity {
+ print!("{}", $msg);
+ }
+ };
+}
+
+/// Writes a message to the error output.
+///
+/// ref: \Composer\IO\IOInterface::writeError()
+#[macro_export]
+macro_rules! console_writeln_error {
+ ($console:expr, $msg:expr $(,)?) => {
+ $crate::console_writeln_error!($console, $msg, $crate::console::Verbosity::Normal)
+ };
+ ($console:expr, $msg:expr, $verbosity:expr $(,)?) => {
+ if ($console).verbosity >= $verbosity {
+ eprintln!("{}", $msg);
+ }
+ };
+}
+
+/// Writes a message to the error output without newline.
+///
+/// ref: \Composer\IO\IOInterface::writeError()
+#[macro_export]
+macro_rules! console_write_error {
+ ($console:expr, $msg:expr $(,)?) => {
+ $crate::console_write_error!($console, $msg, $crate::console::Verbosity::Normal)
+ };
+ ($console:expr, $msg:expr, $verbosity:expr $(,)?) => {
+ if ($console).verbosity >= $verbosity {
+ eprint!("{}", $msg);
+ }
+ };
+}
+
// ---------------------------------------------------------------------------
// Tests
// ---------------------------------------------------------------------------