From 82abb7031496f73950d3ba03b250fb8134b3e562 Mon Sep 17 00:00:00 2001 From: Dennis Date: Thu, 26 Jul 2018 17:17:27 +0200 Subject: [PATCH] Forgot to add this file in commit 3558a4869a10286d7b3fb4cf48559c5e945c98f0 This file is necessary to completely resolve issue #4 --- .../mod.rs} | 0 src/messages.rs | 35 +++++++++++++++++++ 2 files changed, 35 insertions(+) rename src/{key_operations.rs => key_operations/mod.rs} (100%) create mode 100644 src/messages.rs diff --git a/src/key_operations.rs b/src/key_operations/mod.rs similarity index 100% rename from src/key_operations.rs rename to src/key_operations/mod.rs diff --git a/src/messages.rs b/src/messages.rs new file mode 100644 index 0000000..c049787 --- /dev/null +++ b/src/messages.rs @@ -0,0 +1,35 @@ +use colored::*; +use std::process; + +#[macro_export] +macro_rules! info { + ($($arg:tt)*) => { + println!("├ {:7} — {}", "Info".green(), format_args!($($arg)*)); + }; +} + +#[macro_export] +macro_rules! warning { + ($($arg:tt)*) => { + println!("├ {:7} — {}", "Warning".yellow(), format_args!($($arg)*)); + }; +} + +#[macro_export] +macro_rules! error { + ($($arg:tt)*) => { + eprintln!("└ {:7} — {}", "Error".on_red().white(), format_args!($($arg)*)); + process::exit(0); + }; +} + +pub fn welcome(string: &str) { + println!("┌{}┐", "─".repeat(string.len() + 2)); + println!("│{text:^-width$}│", text = string, width = string.len() + 2); + println!("├{}┘", "─".repeat(string.len() + 2)); +} + +pub fn goodbye() { + println!("└ {:7}", "Goodbye!".green()); + process::exit(0); +}