refactor(project): use consistent naming for kernel parameters

This commit is contained in:
Orhun Parmaksız 2021-12-15 17:32:16 +03:00
parent 56a8f40203
commit fb5616f196
No known key found for this signature in database
GPG key ID: F83424824B3E4B90
5 changed files with 13 additions and 13 deletions

View file

@ -1,13 +1,13 @@
/// Possible ways of displaying the kernel variables. /// Possible ways of displaying the kernel parameters.
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub enum DisplayType { pub enum DisplayType {
/// Print the kernel variable name along with its value. /// Print the kernel parameter name along with its value.
Default, Default,
/// Print only the name of the variable. /// Print only the name of the parameter.
Name, Name,
/// Print only the value of the variable. /// Print only the value of the parameter.
Value, Value,
/// Print only the value of the variable without new line. /// Print only the value of the parameter without new line.
Binary, Binary,
} }

View file

@ -23,6 +23,6 @@ pub const SYSTEM_PRELOAD: &[&str] = &[
DEFAULT_PRELOAD, DEFAULT_PRELOAD,
]; ];
/// Deprecated variables to skip while listing. /// Deprecated parameters to skip while listing.
/// <https://bugzilla.redhat.com/show_bug.cgi?id=152435> /// <https://bugzilla.redhat.com/show_bug.cgi?id=152435>
pub const DEPRECATED_VARIABLES: &[&str] = &["base_reachable_time", "retrans_time"]; pub const DEPRECATED_PARAMS: &[&str] = &["base_reachable_time", "retrans_time"];

View file

@ -7,7 +7,7 @@ use systeroid_core::error::Result;
use systeroid_core::parsers::KERNEL_DOCS_PATH; use systeroid_core::parsers::KERNEL_DOCS_PATH;
use systeroid_core::regex::Regex; use systeroid_core::regex::Regex;
use systeroid_core::sysctl::controller::Sysctl; use systeroid_core::sysctl::controller::Sysctl;
use systeroid_core::sysctl::{DEPRECATED_VARIABLES, SYSTEM_PRELOAD}; use systeroid_core::sysctl::{DEPRECATED_PARAMS, SYSTEM_PRELOAD};
use systeroid_parser::globwalk; use systeroid_parser::globwalk;
use systeroid_parser::reader; use systeroid_parser::reader;
@ -50,7 +50,7 @@ impl<'a> App<'a> {
} }
if !display_deprecated { if !display_deprecated {
if let Some(param_name) = parameter.absolute_name() { if let Some(param_name) = parameter.absolute_name() {
return !DEPRECATED_VARIABLES.contains(&param_name); return !DEPRECATED_PARAMS.contains(&param_name);
} }
} }
true true
@ -138,7 +138,7 @@ impl<'a> App<'a> {
if let Some(new_value) = new_value { if let Some(new_value) = new_value {
let config = self.sysctl.config.clone(); let config = self.sysctl.config.clone();
if let Some(param) = self.sysctl.get_parameter(&parameter) { if let Some(param) = self.sysctl.get_parameter(&parameter) {
if DEPRECATED_VARIABLES.contains(&param.absolute_name().unwrap_or_default()) { if DEPRECATED_PARAMS.contains(&param.absolute_name().unwrap_or_default()) {
eprintln!( eprintln!(
"{}: {} is deprecated, value not set", "{}: {} is deprecated, value not set",
env!("CARGO_PKG_NAME"), env!("CARGO_PKG_NAME"),

View file

@ -41,7 +41,7 @@ pub struct Args {
/// Pattern for matching the variables. /// Pattern for matching the variables.
pub pattern: Option<Regex>, pub pattern: Option<Regex>,
/// Whether if the documentation should be shown. /// Whether if the documentation should be shown.
pub explain_params: bool, pub explain: bool,
/// Free string fragments. /// Free string fragments.
pub values: Vec<String>, pub values: Vec<String>,
} }
@ -163,7 +163,7 @@ impl Args {
pattern: matches pattern: matches
.opt_str("r") .opt_str("r")
.map(|v| Regex::new(&v).expect("invalid regex")), .map(|v| Regex::new(&v).expect("invalid regex")),
explain_params: matches.opt_present("E"), explain: matches.opt_present("E"),
values: matches.free, values: matches.free,
}) })
} }

View file

@ -32,7 +32,7 @@ pub fn run(args: Args) -> Result<()> {
app.preload_from_system()?; app.preload_from_system()?;
} else if args.values.is_empty() { } else if args.values.is_empty() {
app.display_parameters(args.pattern, args.display_deprecated)?; app.display_parameters(args.pattern, args.display_deprecated)?;
} else if args.explain_params { } else if args.explain {
app.update_documentation(args.kernel_docs.as_ref())?; app.update_documentation(args.kernel_docs.as_ref())?;
for param in args.values { for param in args.values {
app.display_documentation(&param)?; app.display_documentation(&param)?;