A binary utility that provides a more convenient version of cargo search
.
Grab pre-built binaries for your platform from the releases page.
To grab releases in CI or other automation:
sh
curl -LsSf https://github.com/sunshowers/cargo-search2/releases/latest/download/cargo-search2-{platform}.zip | tar xzf - -C ~/.cargo/bin
Install manually:
sh
cargo install cargo-search2
```sh $ cargo search2 serde
serde 1.0.130 (hash: blake2b24:2e6117acae4f6f2d2d698c9fc0b43de60ac26556f44ad96b)
$ cargo search2 serde --message-format toml serde = "1.0.130"
$ cargo search2 serde --message-format json {"crate-name":"serde","version":"1.0.130","hash":"blake2b24:2e6117acae4f6f2d2d698c9fc0b43de60ac26556f44ad96b"}
$ cargo search2 serde --req '=1.0.120' serde 1.0.120 (hash: blake2b24:f79131f50c298569f841e47287c3b0a443c29cfda3ffd475)
$ cargo run -- serde --req '=1.0.120' -c1 serde 1.0.120 (hash: blake2b24:168778241e3b0e96f5547fba1eb4b4b84efa8291c3c14b37) $ cargo run -- serde --req '=1.0.120' -c2 serde 1.0.120 (hash: blake2b24:344d8a8d08a16dbce8c4e0d90fd6aad513631ca081185ea8)
$ cargo search2 serde --message-format github ::set-output name=crate-name::serde ::set-output name=version::1.0.120 ::set-output name=hash::blake2b24:f79131f50c298569f841e47287c3b0a443c29cfda3ffd475 ```
For an example GitHub Action, see .github/workflows/example.yml
.
People sometimes use cargo search
to generate cache keys for tools. This is an easier way to achieve the same goal with a
couple more features.
cargo search2
supports:
* looking for exact versions and semver ranges
* producing results in plain, JSON, and GitHub Actions formats
* easy cache invalidation through the --cache-version
option
The hashes produced by cargo search2
are derived from:
* The name of the crate
* The exact version number
* The cache version
Notably, the operating system and other parts of the environment are not part of the hash.
Within a semver range, the command-line interface is append-only, and hashes stay the same.
Pull requests are welcome! Please follow the code of conduct.
This project is available under the terms of either the Apache 2.0 license or the MIT license.