-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The synopsis is as follows. List all top-level config keys: $ ruff config allowed-confusables builtins cache-dir ... etc. List all config keys in a specific section: $ ruff config mccabe max-complexity Describe a specific config option: $ ruff config mccabe.max-complexity The maximum McCabe complexity to allow before triggering `C901` errors. Default value: 10 Type: int Example usage: ```toml # Flag errors (`C901`) whenever the complexity level exceeds 5. max-complexity = 5 ```
- Loading branch information
1 parent
bbe4436
commit 0e4d5ee
Showing
5 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use ruff::settings::{ | ||
options::Options, | ||
options_base::{ConfigurationOptions, OptionEntry, OptionField}, | ||
}; | ||
|
||
use crate::ExitStatus; | ||
|
||
#[allow(clippy::print_stdout)] | ||
pub(crate) fn config(option: Option<&str>) -> ExitStatus { | ||
let entries = Options::get_available_options(); | ||
let mut entries = &entries; | ||
|
||
let mut parts_iter = option.iter().flat_map(|s| s.split('.')); | ||
|
||
while let Some(part) = parts_iter.next() { | ||
let Some((_, field)) = entries.iter().find(|(name, _)| *name == part) else { | ||
println!("Unknown option"); | ||
return ExitStatus::Error; | ||
}; | ||
match field { | ||
OptionEntry::Field(OptionField { | ||
doc, | ||
default, | ||
value_type, | ||
example, | ||
}) => { | ||
if parts_iter.next().is_some() { | ||
println!("Unknown option"); | ||
return ExitStatus::Error; | ||
} | ||
|
||
println!("{doc}"); | ||
println!(); | ||
println!("Default value: {default}"); | ||
println!("Type: {value_type}"); | ||
println!("Example usage:\n```toml\n{example}\n```"); | ||
return ExitStatus::Success; | ||
} | ||
OptionEntry::Group(fields) => { | ||
entries = fields; | ||
} | ||
} | ||
} | ||
for (name, _) in entries { | ||
println!("{name}"); | ||
} | ||
ExitStatus::Success | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters