-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
51 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,64 @@ | ||
_ | ||
___ __ _ _ __ __ _ ___ ___| | ___ _ __ ___ | ||
/ __/ _` | '__/ _` |/ _ \ _____ / __| |/ _ \| '_ \ / _ \ | ||
| (_| (_| | | | (_| | (_) |_____| (__| | (_) | | | | __/ | ||
\___\__,_|_| \__, |\___/ \___|_|\___/|_| |_|\___| | ||
|___/ | ||
|
||
cargo-clone can be used to fetch the source code of a Rust crate. | ||
# 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](https://github.com/rust-lang/cargo/wiki/Third-party-cargo-subcommands). | ||
|
||
It can be installed using the install subcommand | ||
# Installation & upgrading | ||
|
||
cargo install cargo-clone | ||
|
||
and can be used like this: | ||
## Usage | ||
|
||
cargo clone [FLAGS] [OPTIONS] <crate>... [-- <directory>] | ||
|
||
To download cargo-clone's code you would use | ||
|
||
cargo clone [options] [<crate>] | ||
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. | ||
|
||
For example, to download version 1.0.0 of cargo-clone's source from crates.io, you would run | ||
|
||
cargo clone cargo-clone@1.0.0 | ||
|
||
Downloading multiple packages is also supported: | ||
Versions are matched exactly by default, but other kinds of matching are also allowed. | ||
|
||
cargo clone cargo-clone@1.0.0 serde time | ||
cargo clone cargo-clone@~1.0.0 | ||
|
||
The output dir can be specified as the last argument: | ||
|
||
cargo clone serde time -- packages/ | ||
### Cloning from git repositories | ||
Using the `--git` flag runs `git clone` on each git repository url extracted from crate's metadata. | ||
|
||
To checkout a git repo specified in the package's Cargo.toml, you can use the `--git` flag: | ||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters