-
Notifications
You must be signed in to change notification settings - Fork 149
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
Merge cargo-add into cargo #568
Comments
Draft of the proposal to mergeThis is a proposal to merge cargo-add into cargo MotivationIn addition to users being used to this as they migrate from other ecosystems (see prior art), this provides guard rails to help the user avoid errors and even guide them to best practices, including
DrawbacksThis is another area of consideration for new RFCs like rust-lang/rfcs#3143 or rust-lang/rfcs#2906 This is a high UX feature that will draw a lot of attention (ie Issue influx), e.g.
BehaviorHelp output $ cargo-add 0.8.0
cargo-add 0.8.0
Add dependency to a Cargo.toml manifest file
USAGE:
cargo add [OPTIONS] <CRATE>...
ARGS:
<CRATE>... Crates to be added
OPTIONS:
--allow-prerelease Include prerelease versions when fetching from crates.io (e.g. '0.6.0-alpha')
-B, --build Add crate as build dependency
--branch <BRANCH> Specify a git branch to download the crate from
-D, --dev Add crate as development dependency
--features <FEATURES> Space-separated list of features to add. For an alternative approach to enabling features, consider installing the `cargo-feature` utility
--git <URI> Specify a git repository to download the crate from
-h, --help Print help information
--manifest-path <PATH> Path to the manifest to add a dependency to
--no-default-features Set `default-features = false` for the added dependency
--offline Run without accessing the network
--optional Add as an optional dependency (for use in features)
-p, --package <PKGID> Package id of the crate to add this dependency to
--path <PATH> Specify the path the crate should be loaded from
--quiet Do not print any output in case of success
-r, --rename <RENAME> Rename a dependency in Cargo.toml, https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#renaming-dependencies-in-cargotoml. Only works when specifying a single dependency
--registry <REGISTRY> Registry to use
--rev <REV> Specify a git branch to download the crate from
-s, --sort Sort dependencies even if currently unsorted
--tag <TAG> Specify a git branch to download the crate from
--target <TARGET> Add as dependency to the given target platform
--upgrade <METHOD> Choose method of semantic version upgrade. Must be one of "none" (exact version, `=` modifier), "patch" (`~` modifier), "minor" (`^` modifier), "all" (`>=`), or "default" (no modifier) [default:
default] [possible values: none, patch, minor, all, default]
-V, --version Print version information
--vers <URI> Specify the version to grab from the registry(crates.io). You can also specify version as part of name, e.g `cargo add bitflags@0.3.2`
This command allows you to add a dependency to a Cargo.toml manifest file. If <crate> is a github or gitlab repository URL, or a local path, `cargo add` will try to automatically get the crate name and set the appropriate `--git` or
`--path` value.
Please note that Cargo treats versions like '1.2.3' as '^1.2.3' (and that '^1.2.3' is specified as '>=1.2.3 and <2.0.0'). By default, `cargo add` will use this format, as it is the one that the crates.io registry suggests. One goal of
`cargo add` is to prevent you from using wildcard dependencies (version set to '*'). Example commands cargo add regex
cargo add regex serde
cargo add regex@1
cargo add regex@~1.0
cargo add regex --vers 1.0
cargo add regex --upgrade minor # for some reason this is the policy name for `^`
cargo add https://github.com/rust-lang/regex
cargo add regex --git https://github.com/rust-lang/regex
cargo add ../dependency
cargo add dep --path ../dependency For an exhaustive set of examples, see test Particular points
AlternativesPrior Art
Future Possibilities
For more, see https://github.com/killercup/cargo-edit/issues?q=is%3Aissue+is%3Aopen+label%3Acargo-add Questions
|
cargo-edit has been added to upstream cargo See also: gh:killercup/cargo-edit/issues/568
This is more a scratchpad for myself to iterate on thoughts without pinging everybody in rust-lang/cargo#8062 (comment)
The text was updated successfully, but these errors were encountered: