4 releases

0.2.3 Aug 24, 2024
0.2.2 Aug 24, 2024
0.2.1 Dec 13, 2023
0.2.0 Jan 25, 2023
0.1.0 Oct 8, 2022

#668 in Cargo plugins

Download history 93/week @ 2024-08-26 43/week @ 2024-09-02 32/week @ 2024-09-09 25/week @ 2024-09-16 22/week @ 2024-09-23 21/week @ 2024-09-30 14/week @ 2024-10-07 29/week @ 2024-10-14 6/week @ 2024-10-21 29/week @ 2024-11-04 10/week @ 2024-11-11 190/week @ 2024-11-18 208/week @ 2024-11-25 24/week @ 2024-12-02 38/week @ 2024-12-09

460 downloads per month
Used in 2 crates (via cargo-clone)

Apache-2.0/MIT

17KB
365 lines

cargo-clone

cargo-clone can be used to fetch the source code of a Rust crate from a registry.

cargo clone [FLAGS] [OPTIONS] <crate>... [-- <directory>]

cargo-clone is a Cargo subcommand.

Installation & upgrading

cargo install cargo-clone

Usage

cargo clone [FLAGS] [OPTIONS] <crate>... [-- <directory>]

To download cargo-clone's code you would use

cargo clone cargo-clone

Specifying versions

The latest available version is downloaded by default. If specific versions are desired, semver specifiers can be appended to crate names.

cargo clone cargo-clone@1.0.0

Versions are matched exactly by default, but other kinds of matching are also allowed.

cargo clone cargo-clone@~1.0.0

Cloning from git repositories

Using the --git flag runs git clone on each git repository url extracted from crate's metadata.

These lines are roughly equivalent:

cargo clone --git cargo-clone
git clone https://github.com/janlikar/cargo-clone

The command fails if a crate does not have the repository field set to a valid git repository.

Output directory

Crates are downloaded into $PWD/$CRATE_NAME by default.

The output dir can be specified as the last argument:

cargo clone cargo-clone -- foo  # Downloads into $PWD/foo

If multiple packages are downloaded at the same time or if the directory contains a trailing slash, the packages will be downloaded into subdirectories of the path provided.

cargo clone cargo-clone -- pkgs/  # Creates pkgs/cargo-clone/
cargo clone cargo serde -- pkgs2/  # Creates pkgs2/cargo and pkgs2/serde

Contributing

Contributions are welcome. Feel free to open a PR into develop branch.

When running locally, you can run using cargo run -- clone CRATE or cargo-clone clone CRATE.

By opening a PR you agree to license your code under Apache/MIT licenses.


lib.rs:

Fetch the source code of a Rust crate from a registry.

Dependencies

~67MB
~1.5M SLoC