refactor(args): remove --no-color argument

This commit is contained in:
Orhun Parmaksız 2021-11-18 20:57:37 +03:00
parent 371c22ac96
commit 5e0725472b
No known key found for this signature in database
GPG key ID: F83424824B3E4B90
2 changed files with 2 additions and 5 deletions

View file

@ -17,8 +17,6 @@ For more details see {bin}(8)."#;
pub struct Args {
/// Path of the Linux kernel documentation.
pub kernel_docs: Option<PathBuf>,
/// Disable colored output.
pub no_color: bool,
/// Parameter to explain.
pub param_to_explain: Option<String>,
/// Parameter names.
@ -34,7 +32,6 @@ impl Args {
opts.optflag("a", "all", "display all variables");
opts.optflag("A", "", "alias of -a");
opts.optflag("X", "", "alias of -a");
opts.optflag("", "no-color", "disable colored output");
opts.optopt(
"",
"explain",
@ -73,7 +70,6 @@ impl Args {
} else {
Some(Args {
kernel_docs: matches.opt_str("d").map(PathBuf::from),
no_color: matches.opt_present("no-color"),
param_to_explain: matches.opt_str("explain"),
param_names: matches.free,
})

View file

@ -9,6 +9,7 @@ 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::Sysctl;
@ -16,7 +17,7 @@ use systeroid_core::sysctl::Sysctl;
/// Runs `systeroid`.
pub fn run(args: Args) -> Result<()> {
let mut config = Config::default();
config.color.no_color = args.no_color;
config.color.no_color = env::var("NO_COLOR").is_ok();
let mut sysctl = Sysctl::init()?;
if let Some(kernel_docs) = args.kernel_docs {