mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-03 15:15:33 +00:00
Add PreviewMode option to formatter
## Summary This PR adds the `--preview` and `--no-preview` options to the `format` command (hidden) and passes it through to the formatte. ## Test Plan I added the `dbg(f.options().preview())` statement in `FormatNodeRule::fmt` and verified that the option gets correctly passed to the formatter.
This commit is contained in:
parent
d9544a2d37
commit
47a253fb62
7 changed files with 54 additions and 7 deletions
|
@ -368,6 +368,12 @@ pub struct FormatCommand {
|
|||
/// The name of the file when passing it through stdin.
|
||||
#[arg(long, help_heading = "Miscellaneous")]
|
||||
pub stdin_filename: Option<PathBuf>,
|
||||
|
||||
/// Enable preview mode; checks will include unstable rules and fixes.
|
||||
#[arg(long, overrides_with("no_preview"), hide = true)]
|
||||
preview: bool,
|
||||
#[clap(long, overrides_with("preview"), hide = true)]
|
||||
no_preview: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, clap::ValueEnum)]
|
||||
|
@ -496,6 +502,7 @@ impl FormatCommand {
|
|||
self.respect_gitignore,
|
||||
self.no_respect_gitignore,
|
||||
),
|
||||
preview: resolve_bool_arg(self.preview, self.no_preview).map(PreviewMode::from),
|
||||
force_exclude: resolve_bool_arg(self.force_exclude, self.no_force_exclude),
|
||||
// Unsupported on the formatter CLI, but required on `Overrides`.
|
||||
..Overrides::default()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue