Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not suggest --package when --backend is used, but --build-backend #10958

Merged
merged 3 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2590,6 +2590,16 @@ pub struct InitArgs {
#[arg(long, value_enum, conflicts_with_all=["script", "no_package"])]
pub build_backend: Option<ProjectBuildBackend>,

/// Invalid option name for build backend.
#[arg(
long,
required(false),
action(clap::ArgAction::SetTrue),
value_parser=clap::builder::UnknownArgumentValueParser::suggest_arg("--build-backend"),
hide(true)
)]
backend: Option<String>,

/// Do not create a `README.md` file.
#[arg(long)]
pub no_readme: bool,
Expand Down
1 change: 1 addition & 0 deletions crates/uv/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ impl InitSettings {
no_pin_python,
no_workspace,
python,
..
} = args;

let kind = match (app, lib, script) {
Expand Down
32 changes: 32 additions & 0 deletions crates/uv/tests/it/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2253,6 +2253,38 @@ fn init_failure() -> Result<()> {
Ok(())
}

#[test]
fn init_failure_with_invalid_option_named_backend() {
let context = TestContext::new("3.12");
uv_snapshot!(context.filters(), context.init().arg("foo").arg("--backend"), @r###"
success: false
exit_code: 2
----- stdout -----

----- stderr -----
error: unexpected argument '--backend' found

tip: a similar argument exists: '--build-backend'

Usage: uv init [OPTIONS] [PATH]

For more information, try '--help'.
"###);
uv_snapshot!(context.filters(), context.init().arg("foo").arg("--backend").arg("maturin"), @r###"
success: false
exit_code: 2
----- stdout -----

----- stderr -----
error: unexpected argument '--backend' found

tip: a similar argument exists: '--build-backend'

Usage: uv init [OPTIONS] [PATH]

For more information, try '--help'.
"###);
}
#[test]
#[cfg(feature = "git")]
fn init_git() -> Result<()> {
Expand Down
Loading