mirror of https://git.sr.ht/~nixgoat/vento
src: Linting and formatting
I passed the file through rustfmt and rust-clippy in order to fulfill some suggestions. Didn't do this before because I didn't have these utilities in hand, but here we go!
This commit is contained in:
parent
56c12f5d4e
commit
52a830331c
|
@ -19,7 +19,7 @@
|
|||
|
||||
use crate::{
|
||||
common,
|
||||
message::{append_emoji, EmojiType}
|
||||
message::{append_emoji, EmojiType},
|
||||
};
|
||||
use anyhow::Result;
|
||||
use colored::Colorize;
|
||||
|
|
|
@ -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<()> {
|
||||
|
|
|
@ -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<()> {
|
||||
|
|
|
@ -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<()> {
|
||||
|
|
|
@ -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<DeserializedConfig> {
|
|||
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);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
14
src/inv.rs
14
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(())
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<String> {
|
||||
let mut output: String = String::new();
|
||||
|
||||
|
||||
if parse_config()?.display_emoji {
|
||||
match message {
|
||||
EmojiType::Celebrate => output = String::from("🎉 "),
|
||||
|
|
Loading…
Reference in New Issue