mirror of
https://github.com/orhun/systeroid
synced 2024-07-21 18:35:03 +00:00
refactor(app): use consistent naming for getter functions
This commit is contained in:
parent
86b7390ecb
commit
c803fe4476
|
@ -65,7 +65,7 @@ impl Sysctl {
|
|||
.filter(|param| {
|
||||
param.name == query.replace('/', ".")
|
||||
|| param.section.to_string() == query
|
||||
|| param.absolute_name() == Some(&query.replace('/', "."))
|
||||
|| param.get_absolute_name() == Some(&query.replace('/', "."))
|
||||
})
|
||||
.collect::<Vec<&Parameter>>();
|
||||
if parameters.is_empty() {
|
||||
|
@ -107,7 +107,7 @@ impl Sysctl {
|
|||
{
|
||||
if let Some(paragraph) =
|
||||
document.paragraphs.par_iter().find_first(|paragraph| {
|
||||
match param.absolute_name() {
|
||||
match param.get_absolute_name() {
|
||||
Some(absolute_name) => {
|
||||
absolute_name.len() > 2
|
||||
&& paragraph.title.contains(absolute_name)
|
||||
|
|
|
@ -45,12 +45,12 @@ impl<'a> TryFrom<&'a Ctl> for Parameter {
|
|||
|
||||
impl Parameter {
|
||||
/// Returns the absolute name of the parameter, without the sections.
|
||||
pub fn absolute_name(&self) -> Option<&str> {
|
||||
pub fn get_absolute_name(&self) -> Option<&str> {
|
||||
self.name.split('.').collect::<Vec<&str>>().last().copied()
|
||||
}
|
||||
|
||||
/// Returns the parameter name with corresponding section colors.
|
||||
pub fn colored_name(&self, config: &Config) -> String {
|
||||
pub fn get_colored_name(&self, config: &Config) -> String {
|
||||
let section_color = *(config
|
||||
.section_colors
|
||||
.get(&self.section)
|
||||
|
@ -109,7 +109,7 @@ impl Parameter {
|
|||
pub fn display_value<Output: Write>(&self, config: &Config, output: &mut Output) -> Result<()> {
|
||||
match config.display_type {
|
||||
DisplayType::Name => {
|
||||
writeln!(output, "{}", self.colored_name(config))?;
|
||||
writeln!(output, "{}", self.get_colored_name(config))?;
|
||||
}
|
||||
DisplayType::Value => {
|
||||
writeln!(output, "{}", self.value.bold())?;
|
||||
|
@ -121,7 +121,7 @@ impl Parameter {
|
|||
writeln!(
|
||||
output,
|
||||
"{} {} {}",
|
||||
self.colored_name(config),
|
||||
self.get_colored_name(config),
|
||||
"=".color(config.default_color),
|
||||
self.value.bold(),
|
||||
)?;
|
||||
|
|
|
@ -76,7 +76,7 @@ impl<'a, Output: Write> App<'a, Output> {
|
|||
return pattern.is_match(¶meter.name);
|
||||
}
|
||||
if !display_deprecated {
|
||||
if let Some(param_name) = parameter.absolute_name() {
|
||||
if let Some(param_name) = parameter.get_absolute_name() {
|
||||
return !DEPRECATED_PARAMS.contains(¶m_name);
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ impl<'a, Output: Write> App<'a, Output> {
|
|||
if let Some(new_value) = new_value {
|
||||
let config = self.sysctl.config.clone();
|
||||
if let Some(param) = self.sysctl.get_parameter(¶meter) {
|
||||
if DEPRECATED_PARAMS.contains(¶m.absolute_name().unwrap_or_default()) {
|
||||
if DEPRECATED_PARAMS.contains(¶m.get_absolute_name().unwrap_or_default()) {
|
||||
eprintln!(
|
||||
"{}: {} is deprecated, value not set",
|
||||
env!("CARGO_PKG_NAME"),
|
||||
|
|
Loading…
Reference in a new issue