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

feat: warning --package will be ignore if --workspace presents #15071

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

linyihai
Copy link
Contributor

@linyihai linyihai commented Jan 16, 2025

What does this PR try to resolve?

Fixes #12978

This PR trigger warning if the specified package is non-existence

How should we test and review this PR?

one commit add test, one commit fixes the issue.

Additional information

set ignore_package as true to indicate that dont pop-up warnning, these commands needs this

  • cargo add
  • cargo remove

@rustbot
Copy link
Collaborator

rustbot commented Jan 16, 2025

r? @weihanglo

rustbot has assigned @weihanglo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-cli Area: Command-line interface, option parsing, etc. Command-add Command-package Command-publish Command-remove Command-tree S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 16, 2025
@@ -185,7 +185,7 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
print_available_packages(&ws)?;
}

let packages = args.packages_from_flags()?;
let packages = args.packages_from_flags(gctx, false)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set ignore_package as true to indicate that dont pop-up warnning, these commands needs this

why does add not need this?

@@ -66,7 +66,7 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
print_available_packages(&workspace)?;
}

let packages = args.packages_from_flags()?;
let packages = args.packages_from_flags(gctx, false)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set ignore_package as true to indicate that dont pop-up warnning, these commands needs this

why does remove not need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add and remove command don't support the --workspace option.

Comment on lines 2658 to 2661
// baz is present in the workspace and it is a real existing package.
p.cargo("check --package baz --workspace")
.with_stderr_data(str![[r#"
[CHECKING] foo v0.1.0 ([ROOT]/foo)
[WARNING] ignoring `--package` as the `--workspace` or `--all` flag is set
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue wasn't about redundant --package flags but about non-existent packages. If we decide to warn on redundant flags, then we can simplify the design of this but that is something that needs to be figured out first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue wasn't about redundant --package flags but about non-existent package.

My PR was deviated from the original question. I tried to add warning for non-existent package.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have a counter proposal, that would ideally be handled in the issue. Let's continue the discussion there

@linyihai linyihai marked this pull request as draft January 17, 2025 07:22
@linyihai linyihai marked this pull request as ready for review January 17, 2025 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cli Area: Command-line interface, option parsing, etc. Command-add Command-package Command-publish Command-remove Command-tree S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

With package selection, --package <non-existent> --workspace doesn't warn or error
4 participants