#cargo #clone #cargo-subcommand #git-clone #git-repository #subcommand

app cargo-clone

A cargo subcommand to fetch the source code of a Rust crate

11 releases (5 stable)

1.2.1 Dec 13, 2023
1.2.0 Jan 25, 2023
1.1.0 Oct 8, 2022
1.0.1 Apr 27, 2022
0.1.0 Apr 16, 2016

#6 in #git-clone

Download history 16/week @ 2023-12-18 2/week @ 2023-12-25 7/week @ 2024-01-01 3/week @ 2024-01-08 4/week @ 2024-01-15 34/week @ 2024-02-19 49/week @ 2024-02-26 14/week @ 2024-03-04 12/week @ 2024-03-11 26/week @ 2024-03-18 172/week @ 2024-04-01

211 downloads per month
Used in cargo-test-all

Apache-2.0/MIT

41KB
492 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 pkgs/cargo and pkgs/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.

Dependencies

~71MB
~1.5M SLoC