Code Monkey home page Code Monkey logo

cargo-edit's Introduction

cargo edit

This tool extends Cargo to allow you to add and list dependencies by reading/writing to your Cargo.toml file from the command line.

Currently available subcommands:

Build Status Coverage Status

Installation

Using cargo install

If you have a recent version of cargo, you can use cargo install to get all the tools provided by cargo-edit in one simple step:

$ cargo install cargo-edit

(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.)

Without cargo install

You can build all commands of cargo-edit from the source available on GitHub:

$ git clone https://github.com/killercup/cargo-edit.git
$ cd cargo-edit
$ cargo build --release

Once you have the executables, you can move them to a directory in your $PATH, e.g.

$ cp target/release/cargo-* ~/.bin/

You should be able to use the new Cargo subcommands now.

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 [email protected] --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/
$ # Also
$ cargo add lib/trial-and-error/

Usage

$ cargo add --help
Usage:
    cargo add <crate> [--dev|--build|--optional] [--ver=<semver>|--git=<uri>|--path=<uri>] [options]
    cargo add (-h|--help)
    cargo add --version

Options:
    -D --dev                Add crate as development dependency.
    -B --build              Add crate as build dependency.
    --ver=<semver>          Specify the version to grab from the registry (crates.io).
                            You can also specify versions as part of the name, e.g
                            `cargo add [email protected]`.
    --git=<uri>             Specify a git repository to download the crate from.
    --path=<uri>            Specify the path the crate should be loaded from.
    --optional              Add as an optional dependency (for use in features.)
    --manifest-path=<path>  Path to the manifest to add a dependency to.
    -h --help               Show this help page.
    --version               Show version.

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. 

cargo list

Examples

$ cargo list
clippy          0.0.19
docopt          0.6
pad             0.1
rustc-serialize 0.3
semver          0.1
toml            0.1
$ cargo list --tree
├── assert_cli (0.1.0)
│   ├── ansi_term (0.6.3)
│   └── difference (0.4.1)
│       └── getopts (0.2.14)
├── clippy (0.0.19)
│   └── unicode-normalization (0.1.1)
├── docopt (0.6.73)
│   ├── regex (0.1.41)
│   │   ├── aho-corasick (0.3.2)
│   │   │   └── memchr (0.1.6)
│   │   │       └── libc (0.1.10)
│   │   ├── memchr (0.1.6)
│   │   │   └── libc (0.1.10)
│   │   └── regex-syntax (0.2.2)
│   ├── rustc-serialize (0.3.16)
│   └── strsim (0.3.0)
├── pad (0.1.4)
│   └── unicode-width (0.1.3)
├── rustc-serialize (0.3.16)
├── semver (0.1.20)
└── toml (0.1.23)
    └── rustc-serialize (0.3.16)

Usage

$ cargo list --help
Usage:
    cargo list [<section>] [options]
    cargo list (-h|--help)
    cargo list --version

Options:
    --manifest-path=<path>  Path to the manifest to add a dependency to.
    --tree                  List dependencies recursively as tree.
    -h --help               Show this help page.

Display a crate's dependencies using its Cargo.toml file.

cargo rm

Remove dependencies from your Cargo.toml.

Examples

$ cargo rm regex
$ cargo rm regex --dev
$ cargo rm regex --build

Usage

$ cargo rm --help
Usage:
    cargo rm <crate> [--dev|--build] [options]
    cargo rm (-h|--help)
    cargo rm --version

Options:
    -D --dev                Remove crate as development dependency.
    -B --build              Remove crate as build dependency.
    --manifest-path=<path>  Path to the manifest to remove a dependency from.
    -h --help               Show this help page.
    --version               Show version.

Remove a dependency to a Cargo.toml manifest file.

License

Apache-2.0/MIT

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.