Repository: astral-sh/uv
File: crates/uv/src/lib.rs (Rust)

Code before:
                writeln!(printer.stdout(), "{:#?}", $arg)?;
                return Ok(ExitStatus::Success);
            }
        };
    }

    // Load environment variables not handled by Clap
    let environment = EnvironmentOptions::new()?;

    match *project_command {
        ProjectCommand::Init(args) => {
            // Resolve the settings from the command-line arguments and workspace configuration.
            let args = settings::InitSettings::resolve(args, filesystem, environment);
            show_settings!(args);

            // The `--project` arg is being deprecated for `init` with a warning now and an error in preview
            if explicit_project {
                if globals.preview.is_enabled(PreviewFeatures::DEPRECATE_PROJECT_FOR_INIT) {
                    bail!(
                        "The argument '--project' cannot be used for 'init'. Consider using `--directory` instead."
                    );
                } else {
                    warn_user!(
                        "The `--project` flag is deprecated for `uv init` and ignored in some cases. Consider using `--directory` to change the working directory instead."
                    );
                }
            }

            // Initialize the cache.
            let cache = cache.init()?;

            commands::init(
                project_dir,
                args.path,
                args.name,
                args.package,
                args.kind,
                args.bare,
                args.description,
                args.no_description,
                args.vcs,
                args.build_backend,
                args.no_readme,
                args.author_from,
                args.pin_python,
                args.python,
                args.install_mirrors,
                args.no_workspace,
                &client_builder,
                globals.python_preference,
                globals.python_downloads,

Review comment (suggestion):
The difference in language between these is confusing, e.g., we're switching between "argument" and "flag" here. I'd say

> The `--project` option cannot be used in `uv init`. Use `--directory` instead.

and

> Use of the `--project` option in `uv init` is deprecated and support will be removed in a future release . Consider using `--directory` instead.



Code after:
                return Ok(ExitStatus::Success);
            }
        };
    }

    // Load environment variables not handled by Clap
    let environment = EnvironmentOptions::new()?;

    match *project_command {
        ProjectCommand::Init(args) => {
            // Resolve the settings from the command-line arguments and workspace configuration.
            let args = settings::InitSettings::resolve(args, filesystem, environment);
            show_settings!(args);

            // The `--project` arg is being deprecated for `init` with a warning now and an error in preview.
            if explicit_project {
                if globals
                    .preview
                    .is_enabled(PreviewFeatures::INIT_PROJECT_FLAG)
                {
                    bail!(
                        "The `--project` option cannot be used in `uv init`. {}",
                        if args.path.is_some() {
                            "Use `--directory` instead."
                        } else {
                            "Use `--directory` or a positional path instead."
                        }
                    )
                }

                warn_user!(
                    "Use of the `--project` option in `uv init` is deprecated and will be removed in a future release. {}",
                    if args.path.is_some() {
                        "Since a positional path was provided, the `--project` option has no effect. Consider using `--directory` instead."
                    } else {
                        "Consider using `uv init <PATH>` instead."
                    }
                );
            }

            // Initialize the cache.
            let cache = cache.init()?;

            commands::init(
                project_dir,
                args.path,
                args.name,
                args.package,
                args.kind,
                args.bare,
                args.description,