diff --git a/src/archive.rs b/src/archive.rs index bab5eec..74c0ba6 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -19,7 +19,7 @@ use crate::{ common, - message::{append_emoji, EmojiType} + message::{append_emoji, EmojiType}, }; use anyhow::Result; use colored::Colorize; diff --git a/src/bin/drop.rs b/src/bin/drop.rs index 5b8f7f7..8548ef8 100644 --- a/src/bin/drop.rs +++ b/src/bin/drop.rs @@ -22,8 +22,9 @@ use std::env; use std::path::Path; use vento::{ common::get_current_dir, + common::override_color, + help, item, message::{throw_error, ErrorType}, - help, item, common::override_color }; fn main() -> Result<()> { diff --git a/src/bin/take.rs b/src/bin/take.rs index 14c1c4b..0a1c553 100644 --- a/src/bin/take.rs +++ b/src/bin/take.rs @@ -20,8 +20,9 @@ use anyhow::Result; use std::env; use vento::{ + common::override_color, + help, item, message::{throw_error, ErrorType}, - help, item, common::override_color }; fn main() -> Result<()> { diff --git a/src/bin/vento.rs b/src/bin/vento.rs index 76210a2..07762ca 100644 --- a/src/bin/vento.rs +++ b/src/bin/vento.rs @@ -21,8 +21,9 @@ use anyhow::Result; use std::{env, path::PathBuf}; use vento::{ archive, + common::override_color, + help, history, inv, message::{throw_error, ErrorType}, - help, history, inv, common::override_color }; fn main() -> Result<()> { diff --git a/src/common.rs b/src/common.rs index 419a0d1..9d32691 100644 --- a/src/common.rs +++ b/src/common.rs @@ -18,8 +18,8 @@ */ use crate::message::{throw_error, ErrorType}; -use colored::control::set_override; use anyhow::Result; +use colored::control::set_override; use config::Config; use std::env::current_dir; use std::fs::File; @@ -106,15 +106,8 @@ pub fn parse_config() -> Result { Err(_) => String::new(), }; - display_emoji = match settings.get_bool("display_emoji") { - Ok(value) => value, - Err(_) => true, - }; - - display_colors = match settings.get_bool("display_colors") { - Ok(value) => value, - Err(_) => true, - }; + display_emoji = settings.get_bool("display_emoji").unwrap_or(true); + display_colors = settings.get_bool("display_colors").unwrap_or(true); } }; diff --git a/src/history.rs b/src/history.rs index 9abccdb..c3d1a6c 100644 --- a/src/history.rs +++ b/src/history.rs @@ -18,9 +18,8 @@ */ use crate::{ - common, - message::{append_emoji, throw_error, ErrorType, EmojiType}, - inv, item, + common, inv, item, + message::{append_emoji, throw_error, EmojiType, ErrorType}, }; use anyhow::Result; use colored::Colorize; diff --git a/src/inv.rs b/src/inv.rs index d5e82ae..37974b0 100644 --- a/src/inv.rs +++ b/src/inv.rs @@ -19,7 +19,7 @@ use super::{ common, - message::{throw_error, append_emoji, ErrorType, EmojiType}, + message::{append_emoji, throw_error, EmojiType, ErrorType}, }; use anyhow::{bail, Context, Result}; use colored::Colorize; @@ -189,7 +189,11 @@ pub fn switch(message: bool) -> Result<()> { })?; if message { - println!("{}{}", append_emoji(EmojiType::Success)?, "Switched inventory slots!".green()); + println!( + "{}{}", + append_emoji(EmojiType::Success)?, + "Switched inventory slots!".green() + ); } Ok(()) } @@ -202,6 +206,10 @@ fn create_slots() -> Result<()> { fs::create_dir_all(active)?; fs::create_dir_all(inactive)?; - println!("{}{}", append_emoji(EmojiType::Celebrate)?, "Vento has been succesfully initialized!".green()); + println!( + "{}{}", + append_emoji(EmojiType::Celebrate)?, + "Vento has been succesfully initialized!".green() + ); Ok(()) } diff --git a/src/item.rs b/src/item.rs index 5365f06..c2af6a7 100644 --- a/src/item.rs +++ b/src/item.rs @@ -19,7 +19,7 @@ use super::{ common, - message::{throw_error, append_emoji, ErrorType, EmojiType}, + message::{append_emoji, throw_error, EmojiType, ErrorType}, }; use anyhow::{bail, Result}; use colored::Colorize; diff --git a/src/lib.rs b/src/lib.rs index c7e45ec..06fb436 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,8 +19,8 @@ pub mod archive; pub mod common; -pub mod message; pub mod help; pub mod history; pub mod inv; pub mod item; +pub mod message; diff --git a/src/message.rs b/src/message.rs index 7812349..61a9f7b 100644 --- a/src/message.rs +++ b/src/message.rs @@ -17,9 +17,9 @@ * */ +use crate::common::parse_config; use anyhow::{bail, Result}; use colored::Colorize; -use crate::common::parse_config; pub enum ErrorType { TooManyArgs, @@ -43,10 +43,9 @@ pub enum EmojiType { Inventory, } - pub fn append_emoji(message: EmojiType) -> Result { let mut output: String = String::new(); - + if parse_config()?.display_emoji { match message { EmojiType::Celebrate => output = String::from("🎉 "),