Deprecation warning for EWW_CPU_USAGE
This commit is contained in:
parent
0a71f3ccf8
commit
fb2bff5137
2 changed files with 14 additions and 12 deletions
|
@ -45,14 +45,6 @@ pub fn get_inbuilt_vars() -> HashMap<VarName, ScriptVarDefinition> {
|
||||||
// @desc EWW_CPU - Information on the CPU cores: frequency and usage (No MacOS support)
|
// @desc EWW_CPU - Information on the CPU cores: frequency and usage (No MacOS support)
|
||||||
"EWW_CPU" => || Ok(DynVal::from(get_cpus())),
|
"EWW_CPU" => || Ok(DynVal::from(get_cpus())),
|
||||||
|
|
||||||
// TODO: Change this eventually, maybe implement an error system
|
|
||||||
// @desc EWW_CPU_USAGE - Outdated, use `EWW_CPU` instead
|
|
||||||
"EWW_CPU_USAGE" => {
|
|
||||||
log::warn!("EWW_CPU_BATTERY is deprecated, use EWW_CPU instead");
|
|
||||||
|| Ok(DynVal::from(get_cpus()))
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
// @desc EWW_NET - Bytes up/down on all interfaces
|
// @desc EWW_NET - Bytes up/down on all interfaces
|
||||||
"EWW_NET" => || Ok(DynVal::from(net())),
|
"EWW_NET" => || Ok(DynVal::from(net())),
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,15 +184,25 @@ impl ToDiagnostic for ValidationError {
|
||||||
"Hint: Define it as a global variable"
|
"Hint: Define it as a global variable"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
diag.with_notes(vec![format!(
|
|
||||||
"Hint: If you meant to use the literal value \"{}\", surround the value in quotes",
|
let mut extra_notes =
|
||||||
name
|
vec![format!("Hint: If you meant to use the literal value \"{}\", surround the value in quotes", name)];
|
||||||
)])
|
|
||||||
|
if let Some(deprecation_note) = variable_deprecation_note(name.to_string()) {
|
||||||
|
extra_notes.push(deprecation_note)
|
||||||
|
};
|
||||||
|
|
||||||
|
diag.with_notes(extra_notes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn variable_deprecation_note(var_name: String) -> Option<String> {
|
||||||
|
(var_name == "EWW_CPU_USAGE")
|
||||||
|
.then(|| "Note: EWW_CPU_USAGE has recently been removed, and has now been renamed to EWW_CPU".to_string())
|
||||||
|
}
|
||||||
|
|
||||||
fn lalrpop_error_to_diagnostic<T: std::fmt::Display, E: Spanned + ToDiagnostic>(
|
fn lalrpop_error_to_diagnostic<T: std::fmt::Display, E: Spanned + ToDiagnostic>(
|
||||||
error: &lalrpop_util::ParseError<usize, T, E>,
|
error: &lalrpop_util::ParseError<usize, T, E>,
|
||||||
file_id: usize,
|
file_id: usize,
|
||||||
|
|
Loading…
Add table
Reference in a new issue