mirror of https://git.sr.ht/~nixgoat/vento
common: Implement display_colors config
This works using the override_color() function within common.rs, which, using colored's set_override function and if set to false in the config file, will disable all coloring within the program, in case your terminal isn't that fancy.
This commit is contained in:
parent
d80ccbea07
commit
c1576270b9
|
@ -23,11 +23,12 @@ use std::path::Path;
|
|||
use vento::{
|
||||
common::get_current_dir,
|
||||
message::{throw_error, ErrorType},
|
||||
help, item,
|
||||
help, item, common::override_color
|
||||
};
|
||||
|
||||
fn main() -> Result<()> {
|
||||
// Handles args in Drop
|
||||
override_color()?;
|
||||
let args: Vec<String> = env::args().collect();
|
||||
if args.len() >= 2 {
|
||||
if args[1].contains("--slot=") {
|
||||
|
|
|
@ -21,11 +21,12 @@ use anyhow::Result;
|
|||
use std::env;
|
||||
use vento::{
|
||||
message::{throw_error, ErrorType},
|
||||
help, item,
|
||||
help, item, common::override_color
|
||||
};
|
||||
|
||||
fn main() -> Result<()> {
|
||||
// Handles args in Vento
|
||||
override_color()?;
|
||||
let args: Vec<String> = env::args().collect();
|
||||
if args.len() >= 2 {
|
||||
if args[1].contains("--slot=") {
|
||||
|
|
|
@ -22,11 +22,12 @@ use std::{env, path::PathBuf};
|
|||
use vento::{
|
||||
archive,
|
||||
message::{throw_error, ErrorType},
|
||||
help, history, inv,
|
||||
help, history, inv, common::override_color
|
||||
};
|
||||
|
||||
fn main() -> Result<()> {
|
||||
// Handles args in Vento
|
||||
override_color()?;
|
||||
let args: Vec<String> = env::args().collect();
|
||||
if args.len() >= 2 {
|
||||
// If the vector for the arguments the command is taking is larger than 2, it most likely means the user has provided an argument
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
use crate::message::{throw_error, ErrorType};
|
||||
use colored::control::set_override;
|
||||
use anyhow::Result;
|
||||
use config::Config;
|
||||
use std::env::current_dir;
|
||||
|
@ -162,3 +163,12 @@ pub fn get_current_dir() -> Result<PathBuf> {
|
|||
|
||||
Ok(currentdir)
|
||||
}
|
||||
|
||||
/// Sets color override if display_colors is disabled
|
||||
pub fn override_color() -> Result<()> {
|
||||
if !parse_config()?.display_colors {
|
||||
set_override(false)
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue