Comments (25)
Yeah, I feel like this is a missing feature, too.
from cargo.
Not sure this should be closed hey, all of npm
's users (which is a pretty large number at this point) are used to passing a --save
flag on install. If cargo doesn't support pinning versions out of the box, the flow will feel awkward to users coming from npm.
I reckon it'd be great for users if cargo supported add
or install --save
out of the box. I don't think it's reasonable for everyone new to Rust to find out about the cargo-edit
through this issue when they get started.
from cargo.
I definitely want cargo add <package-name> [FLAGS]
, which would add the package to the manifest, with optional flags (such as a Github URL if not using the central repo).
Does that sound like what you want?
from cargo.
This should definitely be a native feature of cargo as a package manager. The fact that a third party plugin exists to do this does not mean any less so that this feature should come right out of the box. This issue should still be open.
from cargo.
I've written a help text for the potential new add
command. Any feedback would be very welcome.
Add dependencies to the Cargo.toml file
Usage:
cargo add [options] <crate>...
Options:
-h, --help Print this message
--build Add to the build-dependencies section
--dev Add to the dev-dependencies section
--optional Add as an optional dependency
--features FEATURES Space-separated list of features to also use
--no-default-features Do not use the `default` feature
--target TRIPLE Add dependency only for the target triple
This command will add the specified <crate> to your Cargo.toml file. A <crate>
can be anything of the following:
1) crate name (e.g. `libc`, see https://crates.io/)
2) crate name with a version (e.g. `[email protected]`)
3) local path to another crate (e.g. `../libc`)
4) git url (e.g. `https://github.com/rust-lang/libc`)
5) git url with revision (e.g. `https://github.com/rust-lang/libc#473c10c`)
This command can be used to add multiple crates at once, but any specified
options will apply to all of them.
from cargo.
Once @killercup releases the next version of cargo-edit
, this should be possible to upstream. The non-destructive version is still in beta, though.
from cargo.
Is there a tracking issue for the addition of this feature into Cargo itself (dependent on the destructive-editing issues being resolved)?
Even if it's not immediately implementable, keeping the issue closed seems like the wrong state for an unresolved issue, but perhaps there's another issue thread I've overlooked.
from cargo.
yep, exactly.
from cargo.
There has been some work on this here and here.
from cargo.
@killercup any reason for making this a plugin instead of implementing it right into cargo itself?
from cargo.
@Turbo87 It's nice to test implementations and CLI interfaces in external projects. (Plugin β Built-in is way more easy than Built-in β Plugin.)
from cargo.
I see, thanks
from cargo.
@Turbo87 nice! That's basically a complete docopt definition :)
The equivalent options should work for cargo rm
. (Also, you might want to add --build
for build-dependencies.)
from cargo.
@killercup Thanks for reminding me of the build-dependencies
section. I thought I read about it somewhere but then later I couldn't find anything about it on http://doc.crates.io/manifest.html so I skipped it. I've updated the help text above.
I haven't thought about cargo rm
yet, but it might be something for the future once git add
is implemented.
from cargo.
@Turbo87 I've spend some time this weekend refactoring my cargo-edit
project. It now has a cargo add
binary that looks quite like what you suggested above. I haven't done any extensive testing, but the simple things should work: https://github.com/killercup/cargo-edit
from cargo.
cool, thanks for the feedback. I'll have a look at it once I have a bit of spare time.
from cargo.
With cargo-install
plus cargo-edit
, I'm gonna close this in favor of that repo, thanks @killercup!
from cargo.
We will probably pull cargo-edit into cargo itself, but there are a few issues that need fixed before that's considered. It has basically universal support though.
On Feb 22, 2016, 09:00 -0500, Yoshua [email protected], wrote:
Not sure this should be closed hey, all ofnpm's users (which is a pretty large number at this point) are used to passing a--saveflag on install. If cargo doesn't support pinning versions out of the box, the flow will feel awkward to users coming from npm.
I reckon it'd be great for users if cargo supportedaddorinstall --saveout of the box. I don't think it's reasonable for everyone new to Rust to find out about thecargo-editthrough this issue when they get started.
β
Reply to this email directly orview it on GitHub(#4 (comment)).
from cargo.
Indeed, I'd love to move these in tree! The major blocker is having better support for modifying TOML because today artifacts such as formatting, comments, etc are lost when using cargo-edit
.
from cargo.
What is the state of this? Will cargo add
be a part of Cargo itself in the future? Or should it stay separated in cargo-edit
?
from cargo.
The problems @alexcrichton mentioned in February are still present. There are a few crates that aim to make TOML editing less destructive, but I haven't seen one that is feature-complete enough to be used in cargo-edit. (If that changed since I last looked at itβI would love to see a PR for this! π)
from cargo.
Thanks.
from cargo.
Last comment on 19 Feb 2018, huh? Now, what's the status of this?
Is it now viable to be merged into Cargo? @steveklabnik
from cargo.
#5586 is tracking this nowadays. last comment is from march. still desired, iirc there's still some issues.
from cargo.
This should be closed then in favor of #5586.
EDIT: Nvm, I just saw it is closed lmao.
from cargo.
Related Issues (20)
- Reference staging.crates.io in the Cargo book HOT 4
- Develop against local-only packages without `../../` or absolute paths in dependencies HOT 1
- vsock 0.4.0 fails to compile HOT 3
- Cargo updates registry index on every command
- `cargo package --package` includes all packages if no match is found HOT 2
- worker.js file should be placed into the output directory when targeting Emscripten with pthread support HOT 3
- Cargo packages duplicate files on case-insensitive file systems HOT 2
- Add warning for unused workspace dependency HOT 2
- non-blocking build error reported in example code since 0d62ae2 HOT 7
- Panic on use of libraries with proc-macro examples HOT 3
- maybe a typo issue that make this doc fragment confused HOT 4
- Cargo build/run not working - Bad CPU type in executable HOT 3
- Patching an indirect dependency with `package = "xxx"` renaming HOT 1
- process didn't exit successfully: (signal: 9, SIGKILL: kill) HOT 7
- Support setting target `runner` in the `[profile]` settings HOT 3
- Generate nix package from a crate HOT 2
- `nightly-2024-04-12` selects incorrect version of git dependency HOT 3
- cargo clean fails on projects using cxx for rust <> c++ bindings HOT 3
- ffmpeg-sys vs ffmpeg-sys-next HOT 3
- "cargo new" should add pre-commit hooks for autoformatter and linter HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cargo.