diff --git a/README.md b/README.md index 9c0d399f6..a23dcdf52 100644 --- a/README.md +++ b/README.md @@ -210,13 +210,12 @@ Options: [env: RUST_LOG=] - --linters ... - Enable or disable specific linters. + -W, --warn ... + Enable lint warnings. - This is a comma-separated list of linters to enable or - disable. + This is a comma-separated list of warnings to enable. - Each linter is specified by its name, which is one of: + Each warning is specified by its name, which is one of: * `self-wakes` -- Warns when a task wakes itself more than a certain percentage of its total wakeups. diff --git a/tokio-console/console.example.toml b/tokio-console/console.example.toml index 39ebf05f4..eaff48de3 100644 --- a/tokio-console/console.example.toml +++ b/tokio-console/console.example.toml @@ -1,6 +1,6 @@ default_target_addr = 'http://127.0.0.1:6669/' log = 'off' -linters = [ +warns = [ 'self-wakes', 'lost-waker', 'never-yielded', diff --git a/tokio-console/src/config.rs b/tokio-console/src/config.rs index 3f6c16b94..136af5254 100644 --- a/tokio-console/src/config.rs +++ b/tokio-console/src/config.rs @@ -50,11 +50,11 @@ pub struct Config { #[clap(long = "log", env = "RUST_LOG")] log_filter: Option, - /// Enable or disable specific linters. + /// Enable lint warnings. /// - /// This is a comma-separated list of linters to enable or disable. + /// This is a comma-separated list of warnings to enable. /// - /// Each linter is specified by its name, which is one of: + /// Each warning is specified by its name, which is one of: /// /// * `self-wakes` -- Warns when a task wakes itself more than a certain percentage of its total wakeups. /// @@ -62,13 +62,13 @@ pub struct Config { /// /// * `never-yielded` -- Warns when a task has never yielded. /// - #[clap(long = "linters", value_delimiter = ',', num_args = 1..)] + #[clap(long = "warn", short = 'W', value_delimiter = ',', num_args = 1..)] #[clap(default_values_t = vec![ KnownWarnings::SelfWakes, KnownWarnings::LostWaker, KnownWarnings::NeverYielded ])] - pub(crate) linters: Vec, + pub(crate) warns: Vec, /// Path to a directory to write the console's internal logs to. /// @@ -291,7 +291,7 @@ impl FromStr for LogFilter { struct ConfigFile { default_target_addr: Option, log: Option, - linters: Vec, + warns: Vec, log_directory: Option, retention: Option, charset: Option, @@ -480,12 +480,12 @@ impl Config { log_directory: other.log_directory.or(self.log_directory), target_addr: other.target_addr.or(self.target_addr), log_filter: other.log_filter.or(self.log_filter), - linters: { - let mut linters = other.linters; - linters.extend(self.linters); - linters.sort_unstable(); - linters.dedup(); - linters + warns: { + let mut warns: Vec = other.warns; + warns.extend(self.warns); + warns.sort_unstable(); + warns.dedup(); + warns }, retain_for: other.retain_for.or(self.retain_for), view_options: self.view_options.merge_with(other.view_options), @@ -501,7 +501,7 @@ impl Default for Config { log_filter: Some(LogFilter( filter::Targets::new().with_default(filter::LevelFilter::OFF), )), - linters: vec![ + warns: vec![ KnownWarnings::SelfWakes, KnownWarnings::LostWaker, KnownWarnings::NeverYielded, @@ -741,7 +741,7 @@ impl From for ConfigFile { default_target_addr: config.target_addr.map(|addr| addr.to_string()), log: config.log_filter.map(|filter| filter.to_string()), log_directory: config.log_directory, - linters: config.linters, + warns: config.warns, retention: config.retain_for, charset: Some(CharsetConfig { lang: config.view_options.lang, @@ -764,7 +764,7 @@ impl TryFrom for Config { Ok(Config { target_addr: value.target_addr()?, log_filter: value.log_filter()?, - linters: value.linters.clone(), + warns: value.warns.clone(), log_directory: value.log_directory.take(), retain_for: value.retain_for(), view_options: ViewOptions { diff --git a/tokio-console/src/main.rs b/tokio-console/src/main.rs index 445efdb2f..916af2d54 100644 --- a/tokio-console/src/main.rs +++ b/tokio-console/src/main.rs @@ -66,7 +66,7 @@ async fn main() -> color_eyre::Result<()> { let (details_tx, mut details_rx) = mpsc::channel::(2); let mut state = State::default() - .with_task_linters(args.linters.iter().map(|lint| lint.into())) + .with_task_linters(args.warns.iter().map(|lint| lint.into())) .with_retain_for(retain_for); let mut input = Box::pin(input::EventStream::new().try_filter(|event| { future::ready(!matches!( diff --git a/tokio-console/tests/cli-ui.stdout b/tokio-console/tests/cli-ui.stdout index 29835982f..3bb0bf960 100644 --- a/tokio-console/tests/cli-ui.stdout +++ b/tokio-console/tests/cli-ui.stdout @@ -39,13 +39,12 @@ Options: [env: RUST_LOG=] - --linters ... - Enable or disable specific linters. + -W, --warn ... + Enable lint warnings. - This is a comma-separated list of linters to enable or - disable. + This is a comma-separated list of warnings to enable. - Each linter is specified by its name, which is one of: + Each warning is specified by its name, which is one of: * `self-wakes` -- Warns when a task wakes itself more than a certain percentage of its total wakeups.