mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 06:11:43 +00:00
Add --config as a command-line option (#422)
This commit is contained in:
parent
bcddd9e97f
commit
6b286e9bc1
3 changed files with 10 additions and 1 deletions
|
@ -94,6 +94,8 @@ Arguments:
|
||||||
<FILES>...
|
<FILES>...
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
--config <CONFIG>
|
||||||
|
Path to the `pyproject.toml` file to use for configuration
|
||||||
-v, --verbose
|
-v, --verbose
|
||||||
Enable verbose logging
|
Enable verbose logging
|
||||||
-q, --quiet
|
-q, --quiet
|
||||||
|
@ -132,6 +134,8 @@ Options:
|
||||||
Regular expression matching the name of dummy variables
|
Regular expression matching the name of dummy variables
|
||||||
--target-version <TARGET_VERSION>
|
--target-version <TARGET_VERSION>
|
||||||
The minimum Python version that should be supported
|
The minimum Python version that should be supported
|
||||||
|
--stdin-filename <STDIN_FILENAME>
|
||||||
|
The name of the file when passing it through stdin
|
||||||
-h, --help
|
-h, --help
|
||||||
Print help information
|
Print help information
|
||||||
-V, --version
|
-V, --version
|
||||||
|
|
|
@ -17,6 +17,9 @@ use crate::RawSettings;
|
||||||
pub struct Cli {
|
pub struct Cli {
|
||||||
#[arg(required = true)]
|
#[arg(required = true)]
|
||||||
pub files: Vec<PathBuf>,
|
pub files: Vec<PathBuf>,
|
||||||
|
/// Path to the `pyproject.toml` file to use for configuration.
|
||||||
|
#[arg(long)]
|
||||||
|
pub config: Option<PathBuf>,
|
||||||
/// Enable verbose logging.
|
/// Enable verbose logging.
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
pub verbose: bool,
|
pub verbose: bool,
|
||||||
|
|
|
@ -216,7 +216,9 @@ fn inner_main() -> Result<ExitCode> {
|
||||||
Some(path) => debug!("Found project root at: {:?}", path),
|
Some(path) => debug!("Found project root at: {:?}", path),
|
||||||
None => debug!("Unable to identify project root; assuming current directory..."),
|
None => debug!("Unable to identify project root; assuming current directory..."),
|
||||||
};
|
};
|
||||||
let pyproject = pyproject::find_pyproject_toml(&project_root);
|
let pyproject = cli
|
||||||
|
.config
|
||||||
|
.or_else(|| pyproject::find_pyproject_toml(&project_root));
|
||||||
match &pyproject {
|
match &pyproject {
|
||||||
Some(path) => debug!("Found pyproject.toml at: {:?}", path),
|
Some(path) => debug!("Found pyproject.toml at: {:?}", path),
|
||||||
None => debug!("Unable to find pyproject.toml; using default settings..."),
|
None => debug!("Unable to find pyproject.toml; using default settings..."),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue