Skip to content

Add --public support for cargo add #13037

New issue

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

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

Already on GitHub? # to your account

Closed
Tracked by #44663
epage opened this issue Nov 22, 2023 · 7 comments
Closed
Tracked by #44663

Add --public support for cargo add #13037

epage opened this issue Nov 22, 2023 · 7 comments
Assignees
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-add S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review Z-public-dependency Nightly: public-dependency

Comments

@epage
Copy link
Contributor

epage commented Nov 22, 2023

Problem

rust-lang/rfcs#3516 calls for controlling the new public field in cargo add

Proposed Solution

Add --public and --no-public flags. This will mirror --optional / --no-optional

Test cases

  • Ability to add a new dep that is a public dependency
  • Able to turn an existing private dep into a public dep
  • Able to turn an existing public dep into a private dep

See the test cases for --optional for patterns in naming, etc.

Notes

The RFC called for --public <bool>. ... I don't remember why I did that. I think it might have been due to some aspects of a previous design of the RFC and I forgot to update it. We can note this in the tracking issue for us to approve this deviation.

@epage epage added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing. Command-add labels Nov 22, 2023
@epage epage added S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review Z-public-dependency Nightly: public-dependency and removed S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing. labels Nov 22, 2023
@0xPoe
Copy link
Member

0xPoe commented Nov 23, 2023

@rustbot claim

@epage
Copy link
Contributor Author

epage commented Nov 23, 2023

@hi-rustin if you are ok handing this off, I think @linyihai was interested in contributing to public-private dependencies and I made this as a starting point for them.

@linyihai
Copy link
Contributor

linyihai commented Nov 23, 2023

Never mind, if this issue you are instersted in then i will pick another #13038, it is ok for me :)

@0xPoe
Copy link
Member

0xPoe commented Nov 23, 2023

Oh, I didn't know that. Please feel free to take it.

@0xPoe 0xPoe removed their assignment Nov 23, 2023
@0xPoe
Copy link
Member

0xPoe commented Nov 23, 2023

Oh, I didn't know that.

I found it on the zuilp :(

Please take it and give it a shot! Have a nice hacking time!

@linyihai
Copy link
Contributor

@rustbot claim

bors added a commit that referenced this issue Dec 1, 2023
Add `--public` for `cargo add`

## What does this PR try to resolve?
Complete #13037

This PR want to add `--public/--no public` flag for `cargo add`

Note: this assumes we'll remove workspace inheritance support for `public` as it sounds like we'll be reverting it rust-lang/rust#44663 (comment).  If we decide to keep workspace inheritance, we'll need to come back and update this.

## How should we test and review this PR?
Most of Code were reference `cargo add --optional`, So can reviewed the new code based on the part of  `optional` code.

The new testcases were origin from the `cargo add --optional` part.
- `public` testcase:there is no dependencies and will be add `public` dependencies.
- `no_public` testcase:  there is no dependencies  and will be add `no_public` dependencies.
- `overwrite_public` testcase: the dependencies already exists but will be overwrite with `public`.
- `overwrite_no_public` testcase: the dependencies already exists but will be overwrite with `no_public`.
- `overwrite_public_with_no_public` testcase: the dependencies already marked as `no_public` and will be overwrite with `public`.
- `overwrite_no_public_with_public` testcase: the dependencies already marked as `public` and will be overwrite with `no_public`.
@weihanglo
Copy link
Member

Resolved by #13046. Thank people for your inputs!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-add S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review Z-public-dependency Nightly: public-dependency
Projects
None yet
Development

No branches or pull requests

4 participants