Make isolated a global argument (#3558)

Closes https://github.com/astral-sh/uv/issues/3557.
This commit is contained in:
Charlie Marsh 2024-05-13 13:51:32 -04:00 committed by GitHub
parent 44363d25c2
commit 7ed14fa124
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 7 deletions

View file

@ -35,11 +35,6 @@ pub(crate) struct Cli {
/// The path to a `uv.toml` file to use for configuration.
#[arg(long, env = "UV_CONFIG_FILE", hide = true)]
pub(crate) config_file: Option<PathBuf>,
/// Avoid discovering a `pyproject.toml` or `uv.toml` file in the current directory or any
/// parent directories.
#[arg(long, hide = true)]
pub(crate) isolated: bool,
}
#[derive(Parser, Debug, Clone)]
@ -92,6 +87,11 @@ pub(crate) struct GlobalArgs {
#[arg(global = true, long, overrides_with("preview"), hide = true)]
pub(crate) no_preview: bool,
/// Avoid discovering a `pyproject.toml` or `uv.toml` file in the current directory or any
/// parent directories.
#[arg(global = true, long, hide = true)]
pub(crate) isolated: bool,
}
#[derive(Debug, Clone, clap::ValueEnum)]

View file

@ -112,7 +112,7 @@ async fn run() -> Result<ExitStatus> {
// 3. The user configuration file.
let workspace = if let Some(config_file) = cli.config_file.as_ref() {
Some(uv_workspace::Workspace::from_file(config_file)?)
} else if cli.isolated {
} else if cli.global_args.isolated {
None
} else {
let project = uv_workspace::Workspace::find(env::current_dir()?)?;
@ -524,7 +524,7 @@ async fn run() -> Result<ExitStatus> {
args.args,
requirements,
args.python,
cli.isolated,
globals.isolated,
globals.preview,
&cache,
printer,

View file

@ -34,6 +34,7 @@ pub(crate) struct GlobalSettings {
pub(crate) verbose: u8,
pub(crate) color: ColorChoice,
pub(crate) native_tls: bool,
pub(crate) isolated: bool,
pub(crate) preview: PreviewMode,
}
@ -51,6 +52,7 @@ impl GlobalSettings {
native_tls: flag(args.native_tls, args.no_native_tls)
.or(workspace.and_then(|workspace| workspace.options.native_tls))
.unwrap_or(false),
isolated: args.isolated,
preview: PreviewMode::from(
flag(args.preview, args.no_preview)
.or(workspace.and_then(|workspace| workspace.options.preview))