cargo-edit

授权协议 MIT License
开发语言 Rust
所属分类 应用工具、 终端/远程登录
软件类型 开源软件
地区 不详
投 递 者 聂翼
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

cargo edit

This tool extends Cargo to allow you to add, remove, and upgrade dependencies by modifying your Cargo.toml file from the command line.

Currently available subcommands:

Build Status

Contribution

Thanks for your interest - we gratefully welcome contributions.

Questions can be asked in issues, or on Gitter.

To help us help you get pull requests merged quickly and smoothly, open an issue before submitted large changes. Please keep the contents of pull requests and commits short. Commit messages should include the intent of the commit.

cargo-edit has a moderately comprehensive test suite. Contributions that add/improve tests are awesome. Please add tests for every change.

cargo-edit uses rustfmt for formatting and clippy for linting.

Related Cargo Commands

Installation

Ensure that you have a fairly recent version of rust/cargo installed. On Ubuntu you would also need to install libssl-dev and pkg-config packages.

$ cargo install cargo-edit

If you wish to use a bundled version of openssl:

$ cargo install cargo-edit --features vendored-openssl

Compiler support: requires rustc 1.44+

(Please check cargo's documentation to learn how cargo install works and how to set up your system so it finds binaries installed by cargo.)

Install a sub-set of the commands with cargo install -f --no-default-features --features "<COMMANDS>", where <COMMANDS> is a space-separated list of commands; i.e. add rm upgrade for the full set.

Available Subcommands

cargo add

Add new dependencies to your Cargo.toml. When no version is specified, cargo add will try to query the latest version's number from crates.io.

Examples

$ # Add a specific version
$ cargo add regex@0.1.41 --dev
$ # Query the latest version from crates.io and adds it as build dependency
$ cargo add gcc --build
$ # Add a non-crates.io crate
$ cargo add local_experiment --path=lib/trial-and-error/
$ # Add a non-crates.io crate; the crate name will be found automatically
$ cargo add lib/trial-and-error/
$ # Add a crates.io crate with a local development path
$ cargo add my_helper --vers=1.3.1 --path=lib/my-helper/
$ # Add a renamed dependency
$ cargo add thiserror --rename error

Usage

$ cargo add -h
cargo-add
Add dependency to a Cargo.toml manifest file

USAGE:
    cargo add [FLAGS] [OPTIONS] <crate>...

FLAGS:
        --allow-prerelease       Include prerelease versions when fetching from crates.io (e.g. '0.6.0-alpha')
    -B, --build                  Add crate as build dependency
    -D, --dev                    Add crate as development dependency
    -h, --help                   Prints help information
        --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)
    -q, --quiet                  Do not print any output in case of success
    -s, --sort                   Sort dependencies even if currently unsorted
    -V, --version                Prints version information

OPTIONS:
        --branch <branch>           Specify a git branch to download the crate from
        --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
        --manifest-path <path>      Path to the manifest to add a dependency to
        --path <path>               Specify the path the crate should be loaded from
    -p, --package <pkgid>           Package id of the crate to add this dependency to
        --registry <registry>       Registry to use
    -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
        --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]
        --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`

ARGS:
    <crate>...    Crates to be added


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 '*').

cargo rm

Remove dependencies from your Cargo.toml.

Examples

$ # Remove a dependency
$ cargo rm regex
$ # Remove a development dependency
$ cargo rm regex --dev
$ # Remove a build dependency
$ cargo rm regex --build

Usage

$ cargo rm -h
cargo-rm
Remove a dependency from a Cargo.toml manifest file

USAGE:
    cargo rm [FLAGS] [OPTIONS] <crates>...

FLAGS:
    -B, --build      Remove crate as build dependency
    -D, --dev        Remove crate as development dependency
    -h, --help       Prints help information
    -q, --quiet      Do not print any output in case of success
    -V, --version    Prints version information

OPTIONS:
        --manifest-path <path>    Path to the manifest to remove a dependency from
    -p, --package <package>       Specify the package in the workspace to add a dependency to (see `cargo help pkgid`)

ARGS:
    <crates>...    Crates to be removed

cargo upgrade

Upgrade dependencies in your Cargo.toml to their latest versions.

To specify a version to upgrade to, provide the dependencies in the <crate name>@<version> format,e.g. cargo upgrade docopt@~0.9.0 serde@>=0.9,<2.0.

This command differs from cargo update, which updates the dependency versions recorded in thelocal lock file (Cargo.lock).

Examples

# Upgrade all dependencies for the current crate
$ cargo upgrade
# Upgrade docopt (to ~0.9) and serde (to >=0.9,<2.0)
$ cargo upgrade docopt@~0.9 serde@>=0.9,<2.0
# Upgrade regex (to the latest version) across all crates in the workspace
$ cargo upgrade regex --workspace
# Upgrade all dependencies except docopt and serde
$ cargo upgrade --exclude docopt serde

Usage

$ cargo upgrade -h
cargo-upgrade
Upgrade dependencies as specified in the local manifest file (i.e. Cargo.toml)

USAGE:
    cargo upgrade [FLAGS] [OPTIONS] [dependency]...

FLAGS:
        --workspace           Upgrade all packages in the workspace
        --allow-prerelease    Include prerelease versions when fetching from crates.io (e.g. 0.6.0-alpha')
        --dry-run             Print changes to be made without making them
    -h, --help                Prints help information
        --offline             Run without accessing the network
        --skip-compatible     Only update a dependency if the new version is semver incompatible
        --to-lockfile         Upgrade all packages to the version in the lockfile
    -V, --version             Prints version information

OPTIONS:
        --exclude <exclude>...    Crates to exclude and not upgrade
        --manifest-path <path>    Path to the manifest to upgrade
    -p, --package <package>       Specify the package in the workspace to add a dependency to (see `cargo help pkgid`)

ARGS:
    <dependency>...    Crates to be upgraded

This command differs from `cargo update`, which updates the dependency versions recorded in the
local lock file (Cargo.lock).

If `<dependency>`(s) are provided, only the specified dependencies will be upgraded. The version to
upgrade to for each can be specified with e.g. `docopt@0.8.0` or `serde@>=0.9,<2.0`.

Dev, build, and all target dependencies will also be upgraded. Only dependencies from crates.io are
supported. Git/path dependencies will be ignored.

All packages in the workspace will be upgraded if the `--workspace` flag is supplied.
The `--workspace` flag may be supplied in the presence of a virtual manifest.

If the '--to-lockfile' flag is supplied, all dependencies will be upgraded to the currently locked
version as recorded in the Cargo.lock file. This flag requires that the Cargo.lock file is
up-to-date. If the lock file is missing, or it needs to be updated, cargo-upgrade will exit with an
error. If the '--to-lockfile' flag is supplied then the network won't be accessed.

cargo set-version

Set the version in your Cargo.toml.

Examples

# Set the version to the version 1.0.0
$ cargo set-version 1.0.0
# Bump the version to the next major
$ cargo set-version --bump major
# Bump version to the next minor
$ cargo set-version --bump minor
# Bump version to the next patch
$ cargo set-version --bump patch

Usage

cargo-set-version 0.7.0
Change a package's version in the local manifest file (i.e. Cargo.toml)

USAGE:
    cargo set-version [FLAGS] [OPTIONS] [--] [target]

FLAGS:
        --all          [deprecated in favor of `--workspace`]
        --dry-run      Print changes to be made without making them
    -h, --help         Prints help information
    -V, --version      Prints version information
        --workspace    Modify all packages in the workspace

OPTIONS:
        --bump <bump>             Increment manifest version [possible values: major, minor, patch,
                                  release, rc, beta, alpha]
        --exclude <exclude>...    Crates to exclude and not modify
        --manifest-path <path>    Path to the manifest to upgrade
    -m, --metadata <metadata>     Specify the version metadata field (e.g. a wrapped libraries version)
    -p, --package <pkgid>         Package id of the crate to change the version of

ARGS:
    <target>    Version to change manifests to

For more on metadata, see thesemver crate's documentation.

License

Apache-2.0/MIT

  • 简介 1、cargo-edit cargo-edit 这个工具扩展了 Cargo,允许通过从文件中修改 Cargo.toml 文件来添加。删除和升级依赖项。 2、安装 cargo-edit cargo install cargo-edit 3、cargo-edit可用子命令 cargo add cargo rm cargo upgrade

  • 一、cargo expand简介 cargo expand目前这个需要安装nightly的toolchain,rustup toolchain install nightly-x86_64-unknown-linux-gnu 安装命令:cargo +nightly install cargo-expand 使用方法: use std::result::Result; #[async_std::m

  • 前言 上一篇我们讲了Cargo运行测试 Cargo运行实例 Cargo工作空间 当然,Cargo也能够进行扩展,合并外部工具以增强开发体验,在设计上,其可扩展性已经达到非常丰富和恰当的程度。Cargo可以通过简单的二进制名称(binary-name)语法调用开发人员所创建的命令行工具。 在这一节中,我们就来看看其中的一些经常用得上的工具来帮助我们提升代码的编写效率和可读性。 那么本篇内容涉及子命令

  • APT Config You can genrate the proxy conf in /etc/apt/apt.conf, Or in /etc/apt/apt.conf.d/proxy.conf (1) Method-1 # vim /etc/apt/apt.conf Acquire::http::Proxy "http://PROXYSERVERIP:PROXYPORT"; Acquire

 相关资料
  • Cargo是一个J2EE 容器的轻量级封装,提供操作容器的API Cargo 提供的API 有: 用于启动和停止以及发布新应用到容器的 Java API,同时提供有 ANT、Maven、Intellij IDEA 和 Netbeans 的插件; 用于解析、创建和合并应用的 Java API Cargo 的使用例子: Deployable war = new WAR("path/to/simple.

  • 筒子们好,我们又见面了。之前第5章,我们一起探讨了cargo的一些常用的基本技能。通过第5章的学习,大家基本能解决日常项目开发中遇到的大多数问题。但实际上,cargo提供给我们所使用的功能不仅限于此。我只想说一个字:cargo很好很强大,而且远比你想象的强大。 本章将深入探讨cargo的一些细节问题,这包括以下几个方面: 基于语义化版本的项目版本声明与管理 cargo的toml描述文件配置字段详细

  • 第十二章中,我们构建一个包含二进制 crate 和库 crate 的包。你可能会发现,随着项目开发的深入,库 crate 持续增大,而你希望将其进一步拆分成多个库 crate。对于这种情况,Cargo 提供了一个叫 工作空间(workspaces)的功能,它可以帮助我们管理多个相关的协同开发的包。 工作空间 是一系列共享同样的 Cargo.lock 和输出目录的包。让我们使用工作空间创建一个项目,

  • 曾几何时,对于使用惯了C/C++语言的猿们来说,项目代码的组织与管理绝对是一场噩梦。为了解决C/C++项目的管理问题,猿神们想尽了各种办法,开发出了各种五花八门的项目管理工具,从一开始的automake到后来的cmake、qmake等等,但结果并不如人意,往往是解决了一些问题,却引入了更多的问题,C/C++猿们经常会陷入在掌握语言本身的同时,还要掌握复杂的构建工具语法的窘境。无独有偶,java的项

  • 使用发布配置来自定义构建 使用工作空间来组织更大的项目 使用自定义的命令来扩展 Cargo

  • 我正在尝试使用rust为ios目标制作一个跨平台库。我正在跟随本文(在iOS上构建和部署Rust库)。*注意:我遵循了相同的步骤,我的项目结构看起来也是相同的* 完成代码和项目设置后,最后一步是构建库。当我尝试使用构建库时。它会抛出以下错误: 的库目标 另外,请注意,我只能安装对两个平台的支持。(和)。我认为原因是他们放弃了对32位架构的支持。 因此,当我运行。 它抛出错误: cargo.toml