Git Product home page Git Product logo

Comments (25)

donaldpipowitch avatar donaldpipowitch commented on May 16, 2024 31

Yeah, I feel like this is a missing feature, too.

from cargo.

yoshuawuyts avatar yoshuawuyts commented on May 16, 2024 30

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.

wycats avatar wycats commented on May 16, 2024 23

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.

Progdrasil avatar Progdrasil commented on May 16, 2024 8

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.

Turbo87 avatar Turbo87 commented on May 16, 2024 6

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.

steveklabnik avatar steveklabnik commented on May 16, 2024 5

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.

joepie91 avatar joepie91 commented on May 16, 2024 4

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.

shadowmint avatar shadowmint commented on May 16, 2024 1

yep, exactly.

from cargo.

killercup avatar killercup commented on May 16, 2024

There has been some work on this here and here.

from cargo.

Turbo87 avatar Turbo87 commented on May 16, 2024

@killercup any reason for making this a plugin instead of implementing it right into cargo itself?

from cargo.

killercup avatar killercup commented on May 16, 2024

@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.

Turbo87 avatar Turbo87 commented on May 16, 2024

I see, thanks

from cargo.

killercup avatar killercup commented on May 16, 2024

@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.

Turbo87 avatar Turbo87 commented on May 16, 2024

@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.

killercup avatar killercup commented on May 16, 2024

@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.

Turbo87 avatar Turbo87 commented on May 16, 2024

cool, thanks for the feedback. I'll have a look at it once I have a bit of spare time.

from cargo.

alexcrichton avatar alexcrichton commented on May 16, 2024

With cargo-install plus cargo-edit, I'm gonna close this in favor of that repo, thanks @killercup!

from cargo.

steveklabnik avatar steveklabnik commented on May 16, 2024

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.

alexcrichton avatar alexcrichton commented on May 16, 2024

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.

donaldpipowitch avatar donaldpipowitch commented on May 16, 2024

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.

killercup avatar killercup commented on May 16, 2024

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.

donaldpipowitch avatar donaldpipowitch commented on May 16, 2024

Thanks.

from cargo.

Soupertonic avatar Soupertonic commented on May 16, 2024

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.

steveklabnik avatar steveklabnik commented on May 16, 2024

#5586 is tracking this nowadays. last comment is from march. still desired, iirc there's still some issues.

from cargo.

Soupertonic avatar Soupertonic commented on May 16, 2024

This should be closed then in favor of #5586.

EDIT: Nvm, I just saw it is closed lmao.

from cargo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.