mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-23 13:45:12 +02:00
other: enforce unused_imports lint again (#1189)
* other: enforce unused_imports lint again I think there shouldn't be any issues with enforcing this now... * set up cfg block so the logging feature doesn't break clippy * some cleanup + comments
This commit is contained in:
parent
086b622c66
commit
f0121e6af4
@ -1,13 +1,16 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![deny(rust_2018_idioms)]
|
||||||
#![deny(clippy::todo)]
|
#![deny(clippy::todo)]
|
||||||
#![deny(clippy::unimplemented)]
|
#![deny(clippy::unimplemented)]
|
||||||
#![deny(clippy::missing_safety_doc)]
|
#![deny(clippy::missing_safety_doc)]
|
||||||
#[allow(unused_imports)] // TODO: Deny unused imports.
|
|
||||||
|
|
||||||
// Primarily used for debug purposes.
|
// Primarily used for debug purposes.
|
||||||
#[cfg(feature = "log")]
|
cfg_if::cfg_if! {
|
||||||
#[macro_use]
|
if #[cfg(feature = "log")] {
|
||||||
extern crate log;
|
#[allow(unused_imports)]
|
||||||
|
#[macro_use]
|
||||||
|
extern crate log;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
boxed::Box,
|
boxed::Box,
|
||||||
|
32
src/lib.rs
32
src/lib.rs
@ -5,15 +5,19 @@
|
|||||||
//! than the actual usage of the application. If you are instead looking for documentation regarding the *usage* of
|
//! than the actual usage of the application. If you are instead looking for documentation regarding the *usage* of
|
||||||
//! bottom, refer to [here](https://clementtsang.github.io/bottom/stable/).
|
//! bottom, refer to [here](https://clementtsang.github.io/bottom/stable/).
|
||||||
|
|
||||||
#![warn(rust_2018_idioms)]
|
#![deny(rust_2018_idioms)]
|
||||||
#![deny(clippy::todo)]
|
#![deny(clippy::todo)]
|
||||||
#![deny(clippy::unimplemented)]
|
#![deny(clippy::unimplemented)]
|
||||||
#![deny(clippy::missing_safety_doc)]
|
#![deny(clippy::missing_safety_doc)]
|
||||||
#[allow(unused_imports)] // TODO: Deny unused imports.
|
|
||||||
// Only used for builds not intended for release.
|
// Primarily used for debug purposes.
|
||||||
#[cfg(feature = "log")]
|
cfg_if::cfg_if! {
|
||||||
#[macro_use]
|
if #[cfg(feature = "log")] {
|
||||||
extern crate log;
|
#[allow(unused_imports)]
|
||||||
|
#[macro_use]
|
||||||
|
extern crate log;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
boxed::Box,
|
boxed::Box,
|
||||||
@ -71,6 +75,7 @@ pub type Pid = usize;
|
|||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
pub type Pid = libc::pid_t;
|
pub type Pid = libc::pid_t;
|
||||||
|
|
||||||
|
/// Events sent to the main thread.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum BottomEvent {
|
pub enum BottomEvent {
|
||||||
Resize,
|
Resize,
|
||||||
@ -82,6 +87,7 @@ pub enum BottomEvent {
|
|||||||
Terminate,
|
Terminate,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Events sent to the collection thread.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ThreadEvent {
|
pub enum ThreadEvent {
|
||||||
Reset,
|
Reset,
|
||||||
@ -241,19 +247,17 @@ pub fn read_config(config_location: Option<&String>) -> error::Result<Option<Pat
|
|||||||
pub fn create_or_get_config(config_path: &Option<PathBuf>) -> error::Result<Config> {
|
pub fn create_or_get_config(config_path: &Option<PathBuf>) -> error::Result<Config> {
|
||||||
if let Some(path) = config_path {
|
if let Some(path) = config_path {
|
||||||
if let Ok(config_string) = fs::read_to_string(path) {
|
if let Ok(config_string) = fs::read_to_string(path) {
|
||||||
// We found a config file!
|
|
||||||
Ok(toml_edit::de::from_str(config_string.as_str())?)
|
Ok(toml_edit::de::from_str(config_string.as_str())?)
|
||||||
} else {
|
} else {
|
||||||
// Config file DNE...
|
|
||||||
if let Some(parent_path) = path.parent() {
|
if let Some(parent_path) = path.parent() {
|
||||||
fs::create_dir_all(parent_path)?;
|
fs::create_dir_all(parent_path)?;
|
||||||
}
|
}
|
||||||
// fs::File::create(path)?.write_all(CONFIG_TOP_HEAD.as_bytes())?;
|
|
||||||
fs::File::create(path)?.write_all(CONFIG_TEXT.as_bytes())?;
|
fs::File::create(path)?.write_all(CONFIG_TEXT.as_bytes())?;
|
||||||
Ok(Config::default())
|
Ok(Config::default())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Don't write, the config path was somehow None...
|
// Don't write...
|
||||||
Ok(Config::default())
|
Ok(Config::default())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -264,10 +268,10 @@ pub fn try_drawing(
|
|||||||
) -> error::Result<()> {
|
) -> error::Result<()> {
|
||||||
if let Err(err) = painter.draw_data(terminal, app) {
|
if let Err(err) = painter.draw_data(terminal, app) {
|
||||||
cleanup_terminal(terminal)?;
|
cleanup_terminal(terminal)?;
|
||||||
return Err(err);
|
Err(err)
|
||||||
|
} else {
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cleanup_terminal(
|
pub fn cleanup_terminal(
|
||||||
@ -323,7 +327,7 @@ pub fn panic_hook(panic_info: &PanicInfo<'_>) {
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// Print stack trace. Must be done after!
|
// Print stack trace. Must be done after!
|
||||||
execute!(
|
execute!(
|
||||||
stdout,
|
stdout,
|
||||||
Print(format!(
|
Print(format!(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user