#cargo-registry #semver #index #querying #lookup #versioning #semantic

bin+lib cargo-lookup

Command-line crate registry index querying for Cargo

1 unstable release

0.1.0 Mar 9, 2024

#307 in Cargo plugins

MIT/Apache

23KB
417 lines

Cargo Lookup

A command-line utility for querying Rust crate registry indexes

github

Cargo Lookup allows you to query crate indexes for info about different crates, including features and dependencies. You can also specify semantic versioning requirements to query info for a specific release of a crate!

Installation

The quickest way to install Cargo Lookup is via Cargo

$ cargo install cargo-lookup

Usage

Below are some common usage examples that you might find use of. Run cargo lookup --help to see what else it can do!

List the features of a package

$ cargo lookup libc --type=features
libc:align const-extern-fn default extra_traits rustc-dep-of-std std use_std

Add all features for a package to your project

$ cargo add syn --features=$(cargo lookup syn --format=cargo-add-all)
Updating crates.io index
    Adding syn v2.0.52 to dependencies.
            Features:
            + clone-impls
            + derive
            + extra-traits
            + fold
            + full
            + parsing
            + printing
            + proc-macro
            + quote
            + test
            + visit
            + visit-mut
Updating crates.io index

List the dependencies of packages

$ cargo lookup serde libc --type=deps
libc:rustc-std-workspace-core
serde:serde_derive serde_derive serde_derive

List package info in pretty printed JSON

$ cargo lookup semver --type=json --format=pretty
[
  {
    "name": "semver",
    "vers": "1.0.22",
    "deps": [
      {
        "name": "serde",
        "req": "^1.0.194",
        "features": [],
        "optional": true,
        "default_features": false,
        "target": null,
        "kind": "normal",
        "registry": null,
        "package": null
      }
    ],
    "cksum": "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca",
    "features": {
      "default": [
        "std"
      ],
      "std": []
    },
    "yanked": false,
    "links": null,
    "v": 1,
    "features2": null,
    "rust_version": "^1.31"
  }
]

Dependencies

~2.5–4MB
~100K SLoC