diff --git a/crates/ruff_cli/src/args.rs b/crates/ruff_cli/src/args.rs index 8c9acaa67e..0ddd2f7867 100644 --- a/crates/ruff_cli/src/args.rs +++ b/crates/ruff_cli/src/args.rs @@ -409,6 +409,9 @@ pub struct FormatCommand { force_exclude: bool, #[clap(long, overrides_with("force_exclude"), hide = true)] no_force_exclude: bool, + /// Set the line-length. + #[arg(long, help_heading = "Format configuration")] + pub line_length: Option, /// Ignore all configuration files. #[arg(long, conflicts_with = "config", help_heading = "Miscellaneous")] pub isolated: bool, @@ -552,6 +555,7 @@ impl FormatCommand { stdin_filename: self.stdin_filename, }, CliOverrides { + line_length: self.line_length, respect_gitignore: resolve_bool_arg( self.respect_gitignore, self.no_respect_gitignore, diff --git a/crates/ruff_python_formatter/README.md b/crates/ruff_python_formatter/README.md index 4d52242e08..ee10a695a9 100644 --- a/crates/ruff_python_formatter/README.md +++ b/crates/ruff_python_formatter/README.md @@ -117,10 +117,11 @@ quote-style = "single" ``` The Ruff formatter also respects Ruff's [`line-length`](https://docs.astral.sh/ruff/settings/#line-length) -setting, which also can be provided via a `pyproject.toml` or `ruff.toml` file. +setting, which also can be provided via a `pyproject.toml` or `ruff.toml` file, or on the CLI, as +in: -```toml -line-length = 80 +```console +ruff format --line-length 100 /path/to/file.py ``` ### Excluding code from formatting diff --git a/docs/configuration.md b/docs/configuration.md index de8f4432ae..6fe954c38f 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -402,6 +402,9 @@ File selection: --exclude List of paths, used to omit files and/or directories from analysis --force-exclude Enforce exclusions, even for paths passed to Ruff directly on the command-line. Use `--no-force-exclude` to disable +Format configuration: + --line-length Set the line-length + Log levels: -v, --verbose Enable verbose logging -q, --quiet Print diagnostics, but nothing else