-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[WIP]: Add cargo-add (from cargo-edit) to cargo proper #5611
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Thanks for opening this! Let me know as soon as you want feedback or have questions! |
@killercup inside cargo the data structure for Cargo.toml file is TomlManifest |
After some research I found that cargo's own toml parser doesn't preserve file structure (like comments and whitespaces). It needs to move toml_edit here in addition to cargo-edit. In case to have only one parser. But currently I'm stuck with error kinds while moving manifest file from cargo-edit to cargo. Can you give me an advice how to update these errors to be more appropriate for cargo? |
☔ The latest upstream changes (presumably #5620) made this pull request unmergeable. Please resolve the merge conflicts. |
Thanks for opening this @ibaryshnikov and sorry for the delay! I'm pretty excited to see this start moving and I'm also excited that cargo-edit has come so far! It looks like some of the integration points are still missing here in terms of being a mergeable PR, but in general it may also be worthwhile to discuss integration strategies. First off I'm personaly in favor of merging cargo-edit into Cargo now if it has a style-preserving TOML parser, that's all we were waiting for! Second, though, I think we'll want to integrate the project into Cargo's codebase in an idiomatic fashion with Cargo's own code (aka errors and such). I think for integration though we'll also want to try to avoid having two TOML parsers (if we can). I'd ideally like to keep everything on the same parser if we can to help reduce bugs and such. For example it looks like |
Thank you for the explanations, @alexcrichton ! I've just replaced ErrorKind errors with format_err macro. The next step is to find a way to replace chain_err. |
Ok, great! |
ping @ibaryshnikov, have you had a chance to work on this recently? |
not yet ( |
Found out how to deal with chain_err. Now I'm going to find how to use tokens.rs here |
Hello, author of toml_edit. I'm happy to help to make this happen.
Actually |
@ordian ok that'd be great yeah! That would deduplicate some of the most complicated parts of TOML parsing which would work well. Currently the |
Implemented minimal working example using toml_edit in its current state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is a good way to specify versions? cargo install subcommand uses --version flag, and in cargo_edit we can see both flag and name@version pattern.
I think we should be consistent with cargo update
, so consider using --precise
flag (w/o name@version).
Also I would suggest using more recent version of |
Thank you for your comments, @ordian ! I picked the latest code from cargo-edit for dependency.rs
produces
|
Ok this has been a bit stale for quite some time now, so I'm going to close this at this time. The Cargo team very much wants to add this, however, and we'll be looking into allocating resources to implement this change in early 2019 hopefully! |
@alexcrichton have you had a chance to look through the code before closing it? I was waiting for your comments. I mean, allocating some resources would be helpful, but may be some changes from this PR could be used, too. |
@ibaryshnikov unfortunately no I didn't have time to do a thorough review (and it looks like no others did either). Reviewing this will likely require a pretty significant investment from someone on the Cargo team because it's a very highly-desired and relatively large piece of new functionality. There's quite a lot of code to review here not only in this repository but in the crates.io dependencies. |
@alexcrichton do you know anyone who can do the review? |
@rust-lang/cargo would others be able to help out in reviewing this? @ibaryshnikov is requesting a review. Ah sorry @ibaryshnikov but this probably should definitely not be classified as an easy task, that was a mistake :( |
any status? |
Implements #5586
The work is at early stage and contains mostly code copied from
cargo install
command. But it compiles and it is possible to call the subcommand:./target/debug/cargo add some_crate
I've opened this pr to discuss the key decisions during the implementation process.