mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 20:09:22 +00:00
refactor: Replace Vec
in options metadata with static array (#3433)
This commit is contained in:
parent
1e081cf9a6
commit
cc8b13d3a7
7 changed files with 204 additions and 81 deletions
|
@ -1,35 +1,19 @@
|
|||
use crate::ExitStatus;
|
||||
use ruff::settings::{
|
||||
options::Options,
|
||||
options_base::{ConfigurationOptions, OptionEntry, OptionField},
|
||||
};
|
||||
use ruff::settings::options::Options;
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
pub(crate) fn config(key: Option<&str>) -> ExitStatus {
|
||||
let Some(entry) = Options::get(key) else {
|
||||
println!("Unknown option");
|
||||
return ExitStatus::Error;
|
||||
};
|
||||
|
||||
match entry {
|
||||
OptionEntry::Field(OptionField {
|
||||
doc,
|
||||
default,
|
||||
value_type,
|
||||
example,
|
||||
}) => {
|
||||
println!("{doc}");
|
||||
println!();
|
||||
println!("Default value: {default}");
|
||||
println!("Type: {value_type}");
|
||||
println!("Example usage:\n```toml\n{example}\n```");
|
||||
}
|
||||
OptionEntry::Group(entries) => {
|
||||
for (name, _) in entries {
|
||||
println!("{name}");
|
||||
match key {
|
||||
None => print!("{}", Options::metadata()),
|
||||
Some(key) => match Options::metadata().get(key) {
|
||||
None => {
|
||||
println!("Unknown option");
|
||||
return ExitStatus::Error;
|
||||
}
|
||||
}
|
||||
Some(entry) => {
|
||||
print!("{entry}");
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
ExitStatus::Success
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue