mirror of
https://github.com/orhun/kmon
synced 2024-06-29 06:24:54 +00:00
refactor: Apply clippy suggestions
This commit is contained in:
parent
2367b583e0
commit
ad4622be63
2
build.rs
2
build.rs
|
@ -29,7 +29,7 @@ fn build_manpage(out_dir: &Path) -> Result<(), IoError> {
|
|||
fs::create_dir_all(out_dir)?;
|
||||
let app = args::get_args();
|
||||
let file = out_dir.join(format!("{}.8", env!("CARGO_PKG_NAME")));
|
||||
let mut file = File::create(&file)?;
|
||||
let mut file = File::create(file)?;
|
||||
Man::new(app).render(&mut file)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
10
src/app.rs
10
src/app.rs
|
@ -125,7 +125,7 @@ impl Display for InputMode {
|
|||
None => input_mode,
|
||||
}
|
||||
}
|
||||
write!(f, "{:?}", input_mode)
|
||||
write!(f, "{input_mode:?}")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,7 +241,7 @@ impl App {
|
|||
pub fn set_clipboard_contents(&mut self, contents: &str) {
|
||||
if let Some(clipboard) = self.clipboard.as_mut() {
|
||||
if let Err(e) = clipboard.set_contents(contents.to_string()) {
|
||||
eprintln!("{}", e);
|
||||
eprintln!("{e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ impl App {
|
|||
format!("{}:", &key),
|
||||
self.style.colored,
|
||||
)));
|
||||
help_text_raw.push(format!("{}:", key));
|
||||
help_text_raw.push(format!("{key}:"));
|
||||
help_text.push(Spans::from(Span::styled(
|
||||
format!("{}{}", self.style.unicode.get(Symbol::Blank), &desc),
|
||||
self.style.default,
|
||||
|
@ -308,7 +308,7 @@ impl App {
|
|||
for module in &dependent_modules_list {
|
||||
dependent_modules.push(Spans::from(vec![
|
||||
Span::styled("-", self.style.colored),
|
||||
Span::styled(format!(" {}", module), self.style.default),
|
||||
Span::styled(format!(" {module}"), self.style.default),
|
||||
]));
|
||||
}
|
||||
kernel_modules.current_info.set(
|
||||
|
@ -560,7 +560,7 @@ impl App {
|
|||
.options
|
||||
.items
|
||||
.iter()
|
||||
.map(|(_, text)| ListItem::new(Span::raw(format!(" {}", text))))
|
||||
.map(|(_, text)| ListItem::new(Span::raw(format!(" {text}"))))
|
||||
.collect::<Vec<ListItem<'_>>>();
|
||||
let (mut percent_y, mut percent_x) = (40, 60);
|
||||
let text_height = items.iter().map(|v| v.height() as f32).sum::<f32>() + 3.;
|
||||
|
|
|
@ -76,7 +76,7 @@ impl ModuleCommand {
|
|||
*/
|
||||
pub fn get(self, module_name: &str) -> Command {
|
||||
match self {
|
||||
Self::None => Command::new(String::from(""), "", format!("Module: {}", module_name), Symbol::None),
|
||||
Self::None => Command::new(String::from(""), "", format!("Module: {module_name}"), Symbol::None),
|
||||
Self::Load => Command::new(
|
||||
if Self::is_module_filename(module_name) {
|
||||
format!("insmod {}", &module_name)
|
||||
|
@ -85,7 +85,7 @@ impl ModuleCommand {
|
|||
},
|
||||
"Add and remove modules from the Linux Kernel\n
|
||||
This command inserts a module to the kernel.",
|
||||
format!("Load: {}", module_name), Symbol::Anchor),
|
||||
format!("Load: {module_name}"), Symbol::Anchor),
|
||||
Self::Unload => Command::new(
|
||||
format!("modprobe -r {0} || rmmod {0}", &module_name),
|
||||
"modprobe/rmmod: Add and remove modules from the Linux Kernel
|
||||
|
@ -97,14 +97,14 @@ impl ModuleCommand {
|
|||
There is usually no reason to remove modules, but some buggy \
|
||||
modules require it. Your distribution kernel may not have been \
|
||||
built to support removal of modules at all.",
|
||||
format!("Remove: {}", module_name), Symbol::CircleX),
|
||||
format!("Remove: {module_name}"), Symbol::CircleX),
|
||||
Self::Reload => Command::new(
|
||||
format!("{} && {}",
|
||||
ModuleCommand::Unload.get(module_name).cmd,
|
||||
ModuleCommand::Load.get(module_name).cmd),
|
||||
"modprobe/insmod/rmmod: Add and remove modules from the Linux Kernel\n
|
||||
This command reloads a module, removes and inserts to the kernel.",
|
||||
format!("Reload: {}", module_name), Symbol::FuelPump),
|
||||
format!("Reload: {module_name}"), Symbol::FuelPump),
|
||||
Self::Blacklist => Command::new(
|
||||
format!("if ! grep -q {module} /etc/modprobe.d/blacklist.conf; then
|
||||
echo 'blacklist {module}' >> /etc/modprobe.d/blacklist.conf
|
||||
|
@ -120,7 +120,7 @@ impl ModuleCommand {
|
|||
this behaviour; the install command instructs modprobe to run a custom command \
|
||||
instead of inserting the module in the kernel as normal, so the module will \
|
||||
always fail to load.",
|
||||
format!("Blacklist: {}", module_name), Symbol::SquareX),
|
||||
format!("Blacklist: {module_name}"), Symbol::SquareX),
|
||||
Self::Clear => Command::new(
|
||||
String::from("dmesg --clear"),
|
||||
"dmesg: Print or control the kernel ring buffer
|
||||
|
|
|
@ -277,7 +277,7 @@ impl KernelModules<'_> {
|
|||
if let Some(v) = self
|
||||
.list
|
||||
.iter()
|
||||
.position(|module| module[0] == format!(" {}", used_module))
|
||||
.position(|module| module[0] == format!(" {used_module}"))
|
||||
{
|
||||
match v {
|
||||
0 => {
|
||||
|
|
|
@ -67,7 +67,7 @@ impl KernelLogs {
|
|||
})
|
||||
.unwrap_or(0),
|
||||
)
|
||||
.map(|i| format!("{}\n", i))
|
||||
.map(|i| format!("{i}\n"))
|
||||
.collect::<String>();
|
||||
&self.selected_output
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ impl Style {
|
|||
];
|
||||
match args.try_get_one::<String>(arg_name) {
|
||||
Ok(Some(v)) => *colors.get::<str>(&v.to_lowercase()).unwrap_or({
|
||||
if let Ok(rgb) = Rgb::from_hex_str(&format!("#{}", v)) {
|
||||
if let Ok(rgb) = Rgb::from_hex_str(&format!("#{v}")) {
|
||||
Box::leak(Box::new(Color::Rgb(
|
||||
rgb.red() as u8,
|
||||
rgb.green() as u8,
|
||||
|
|
Loading…
Reference in New Issue
Block a user