mirror of
https://github.com/orhun/systeroid
synced 2024-07-21 10:25:00 +00:00
refactor(config): remove no_color field
This commit is contained in:
parent
5ce0fde69b
commit
21db751458
|
@ -21,8 +21,6 @@ pub struct Config {
|
|||
pub ignore_errors: bool,
|
||||
/// Whether if the quiet mode is enabled.
|
||||
pub quiet: bool,
|
||||
/// Whether if the colors are disabled.
|
||||
pub no_color: bool,
|
||||
/// Whether if the pager is disabled.
|
||||
pub no_pager: bool,
|
||||
/// Sections and the corresponding colors.
|
||||
|
@ -39,7 +37,6 @@ impl Default for Config {
|
|||
verbose: false,
|
||||
ignore_errors: false,
|
||||
quiet: false,
|
||||
no_color: false,
|
||||
no_pager: false,
|
||||
section_colors: map! {
|
||||
Section::Abi => Color::Red,
|
||||
|
|
|
@ -75,41 +75,24 @@ impl Parameter {
|
|||
|
||||
/// Prints the kernel parameter to given output.
|
||||
pub fn display_value<W: Write>(&self, config: &Config, output: &mut W) -> Result<()> {
|
||||
if !config.no_color {
|
||||
match config.display_type {
|
||||
DisplayType::Name => {
|
||||
writeln!(output, "{}", self.colored_name(config))?;
|
||||
}
|
||||
DisplayType::Value => {
|
||||
writeln!(output, "{}", self.value.bold())?;
|
||||
}
|
||||
DisplayType::Binary => {
|
||||
write!(output, "{}", self.value.bold())?;
|
||||
}
|
||||
DisplayType::Default => {
|
||||
writeln!(
|
||||
output,
|
||||
"{} {} {}",
|
||||
self.colored_name(config),
|
||||
"=".color(config.default_color),
|
||||
self.value.bold(),
|
||||
)?;
|
||||
}
|
||||
match config.display_type {
|
||||
DisplayType::Name => {
|
||||
writeln!(output, "{}", self.colored_name(config))?;
|
||||
}
|
||||
} else {
|
||||
match config.display_type {
|
||||
DisplayType::Name => {
|
||||
writeln!(output, "{}", self.name)?;
|
||||
}
|
||||
DisplayType::Value => {
|
||||
writeln!(output, "{}", self.value)?;
|
||||
}
|
||||
DisplayType::Binary => {
|
||||
write!(output, "{}", self.value)?;
|
||||
}
|
||||
DisplayType::Default => {
|
||||
writeln!(output, "{} = {}", self.name, self.value)?;
|
||||
}
|
||||
DisplayType::Value => {
|
||||
writeln!(output, "{}", self.value.bold())?;
|
||||
}
|
||||
DisplayType::Binary => {
|
||||
write!(output, "{}", self.value.bold())?;
|
||||
}
|
||||
DisplayType::Default => {
|
||||
writeln!(
|
||||
output,
|
||||
"{} {} {}",
|
||||
self.colored_name(config),
|
||||
"=".color(config.default_color),
|
||||
self.value.bold(),
|
||||
)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
@ -9,7 +9,6 @@ pub mod args;
|
|||
|
||||
use crate::app::App;
|
||||
use crate::args::Args;
|
||||
use std::env;
|
||||
use systeroid_core::config::Config;
|
||||
use systeroid_core::error::Result;
|
||||
use systeroid_core::sysctl::controller::Sysctl;
|
||||
|
@ -22,7 +21,6 @@ pub fn run(args: Args) -> Result<()> {
|
|||
quiet: args.quiet,
|
||||
no_pager: args.no_pager,
|
||||
display_type: args.display_type,
|
||||
no_color: env::var("NO_COLOR").is_ok(),
|
||||
..Default::default()
|
||||
};
|
||||
let mut sysctl = Sysctl::init(config)?;
|
||||
|
|
Loading…
Reference in a new issue