Skip to content

Commit

Permalink
refactor: rename to warn
Browse files Browse the repository at this point in the history
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
  • Loading branch information
Rustin170506 committed Nov 29, 2023
1 parent d161904 commit 87559ea
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 27 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,12 @@ Options:
[env: RUST_LOG=]
--linters <LINTERS>...
Enable or disable specific linters.
-W, --warn <WARNS>...
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.
Expand Down
2 changes: 1 addition & 1 deletion tokio-console/console.example.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
default_target_addr = 'http://127.0.0.1:6669/'
log = 'off'
linters = [
warns = [
'self-wakes',
'lost-waker',
'never-yielded',
Expand Down
30 changes: 15 additions & 15 deletions tokio-console/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,25 @@ pub struct Config {
#[clap(long = "log", env = "RUST_LOG")]
log_filter: Option<LogFilter>,

/// 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.
///
/// * `lost-waker` -- Warns when a task is dropped without being woken.
///
/// * `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<KnownWarnings>,
pub(crate) warns: Vec<KnownWarnings>,

/// Path to a directory to write the console's internal logs to.
///
Expand Down Expand Up @@ -291,7 +291,7 @@ impl FromStr for LogFilter {
struct ConfigFile {
default_target_addr: Option<String>,
log: Option<String>,
linters: Vec<KnownWarnings>,
warns: Vec<KnownWarnings>,
log_directory: Option<PathBuf>,
retention: Option<RetainFor>,
charset: Option<CharsetConfig>,
Expand Down Expand Up @@ -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<KnownWarnings> = 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),
Expand All @@ -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,
Expand Down Expand Up @@ -741,7 +741,7 @@ impl From<Config> 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,
Expand All @@ -764,7 +764,7 @@ impl TryFrom<ConfigFile> 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 {
Expand Down
2 changes: 1 addition & 1 deletion tokio-console/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async fn main() -> color_eyre::Result<()> {
let (details_tx, mut details_rx) = mpsc::channel::<TaskDetails>(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!(
Expand Down
9 changes: 4 additions & 5 deletions tokio-console/tests/cli-ui.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ Options:

[env: RUST_LOG=]

--linters <LINTERS>...
Enable or disable specific linters.
-W, --warn <WARNS>...
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.
Expand Down

0 comments on commit 87559ea

Please sign in to comment.