-
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.
Refactor ruff_cli's run method to return on each branch (#7040)
## Summary I think the fallthrough here for some branches is a little confusing. Now each branch either runs a command that returns `Result<ExitStatus>`, or runs a command that returns `Result<()>` and then explicitly returns `Ok(ExitStatus::SUCCESS)`.
- Loading branch information
1 parent
0489bbc
commit 08e2467
Showing
2 changed files
with
21 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
use crate::ExitStatus; | ||
use anyhow::{anyhow, Result}; | ||
|
||
use ruff_workspace::options::Options; | ||
|
||
#[allow(clippy::print_stdout)] | ||
pub(crate) fn config(key: Option<&str>) -> ExitStatus { | ||
pub(crate) fn config(key: Option<&str>) -> Result<()> { | ||
match key { | ||
None => print!("{}", Options::metadata()), | ||
Some(key) => match Options::metadata().get(key) { | ||
None => { | ||
println!("Unknown option"); | ||
return ExitStatus::Error; | ||
return Err(anyhow!("Unknown option: {key}")); | ||
} | ||
Some(entry) => { | ||
print!("{entry}"); | ||
} | ||
}, | ||
} | ||
ExitStatus::Success | ||
Ok(()) | ||
} |
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