-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add info
cargo subcommand
#14141
Conversation
e5feb74
to
b9965c6
Compare
I remembered last time when we imported new commands we insta-stablized them ( If the Cargo team are happy with making this a built-in command, I suppose we could do the same thing. |
f582df0
to
476969f
Compare
1484d46
to
55db322
Compare
55db322
to
7736762
Compare
791dad8
to
242919d
Compare
I tested it locally: ❯ ./target/debug/cargo logout
Logout token for `crates-io` has been removed from local storage
note: This does not revoke the token on the registry server.
If you need to revoke the token, visit <https://crates.io/me> and follow the instructions there.
cargo on rustin-patch-info is 📦 v0.83.0 via 🐍 v3.12.4 via 🦀 v1.82.0-nightly
❯ ./target/debug/cargo info serde
serde #serde #serialization #no_std
A generic serialization/deserialization framework
version: 1.0.204
license: MIT OR Apache-2.0
rust-version: 1.31
documentation: https://docs.rs/serde
homepage: https://serde.rs
repository: https://github.com/serde-rs/serde
crates.io: https://crates.io/crates/serde/1.0.204
features:
+default = [std]
std = []
alloc = []
derive = [serde_derive]
rc = []
serde_derive = [dep:serde_derive]
unstable = []
note: to see how you depend on serde, run `cargo tree --invert --package serde@1.0.204` It seemed it doesn't require it. |
156c865
to
a4c7dfc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔢 Self-check (PR reviewed by myself and ready for feedback.)
a4c7dfc
to
ba07215
Compare
I also logged out and couldn't reproduce. As we develop reproduction steps, we can iterate from there. @bors r+ |
☀️ Test successful - checks-actions |
1 similar comment
☀️ Test successful - checks-actions |
👀 Test was successful, but fast-forwarding failed: 422 Changes must be made through a pull request. |
Update cargo 7 commits in 0d8d22f83b066503f6b2b755925197e959e58b4f..2f738d617c6ead388f899802dd1a7fd66858a691 2024-08-08 12:54:24 +0000 to 2024-08-13 10:57:52 +0000 - chore: downgrade to openssl v1.1.1 (again) (rust-lang/cargo#14391) - feat(trim-paths): rustdoc supports trim-paths for diagnostics (rust-lang/cargo#14389) - Use longhand gitoxide path-spec patterns (rust-lang/cargo#14380) - feat: Add `info` cargo subcommand (rust-lang/cargo#14141) - CI: Switch macos aarch64 to nightly (rust-lang/cargo#14382) - Use context instead of with_context (rust-lang/cargo#14377) - Fix: `cargo package` failed on bare commit git repo. (rust-lang/cargo#14359) r? ghost
Update cargo 7 commits in 0d8d22f83b066503f6b2b755925197e959e58b4f..2f738d617c6ead388f899802dd1a7fd66858a691 2024-08-08 12:54:24 +0000 to 2024-08-13 10:57:52 +0000 - chore: downgrade to openssl v1.1.1 (again) (rust-lang/cargo#14391) - feat(trim-paths): rustdoc supports trim-paths for diagnostics (rust-lang/cargo#14389) - Use longhand gitoxide path-spec patterns (rust-lang/cargo#14380) - feat: Add `info` cargo subcommand (rust-lang/cargo#14141) - CI: Switch macos aarch64 to nightly (rust-lang/cargo#14382) - Use context instead of with_context (rust-lang/cargo#14377) - Fix: `cargo package` failed on bare commit git repo. (rust-lang/cargo#14359) r? ghost
Update cargo 7 commits in 0d8d22f83b066503f6b2b755925197e959e58b4f..2f738d617c6ead388f899802dd1a7fd66858a691 2024-08-08 12:54:24 +0000 to 2024-08-13 10:57:52 +0000 - chore: downgrade to openssl v1.1.1 (again) (rust-lang/cargo#14391) - feat(trim-paths): rustdoc supports trim-paths for diagnostics (rust-lang/cargo#14389) - Use longhand gitoxide path-spec patterns (rust-lang/cargo#14380) - feat: Add `info` cargo subcommand (rust-lang/cargo#14141) - CI: Switch macos aarch64 to nightly (rust-lang/cargo#14382) - Use context instead of with_context (rust-lang/cargo#14377) - Fix: `cargo package` failed on bare commit git repo. (rust-lang/cargo#14359) r? ghost
Opened #14409 regarding the authentication problem. |
Update cargo 7 commits in 0d8d22f83b066503f6b2b755925197e959e58b4f..2f738d617c6ead388f899802dd1a7fd66858a691 2024-08-08 12:54:24 +0000 to 2024-08-13 10:57:52 +0000 - chore: downgrade to openssl v1.1.1 (again) (rust-lang/cargo#14391) - feat(trim-paths): rustdoc supports trim-paths for diagnostics (rust-lang/cargo#14389) - Use longhand gitoxide path-spec patterns (rust-lang/cargo#14380) - feat: Add `info` cargo subcommand (rust-lang/cargo#14141) - CI: Switch macos aarch64 to nightly (rust-lang/cargo#14382) - Use context instead of with_context (rust-lang/cargo#14377) - Fix: `cargo package` failed on bare commit git repo. (rust-lang/cargo#14359) r? ghost
close #14081
close #948
fcp #14141 (comment)
This PR added a new
info
cargo subcommand.Background
This adds a new subcommand to Cargo,
cargo info
. This subcommand would allow users to get information about a crate from the command line, without having to go to the web.The main motivation for this is to make it easier to get information about a crate from the command line. Currently, the way to get information about a crate is to go to the web and look it up on crates.io or find the crate's source code and look at the
Cargo.toml
file. This is not very convenient, especially not all information is displayed on the crates.io page.This command also has been requested by the community for a long time. You can find more discussion about this in cargo#948.
Another motivation is to make the workflow of finding and evaluating crates more efficient. In the current workflow, users can search for crates using
cargo search
, but then they have to go to the web to get more information about the crate. This is not very efficient, especially if the user is just trying to get a quick overview of the crate. This would allow users to quickly get information about a crate without having to leave the terminal.Example usage:
note: this is showing the
--verbose
output to show every thing the user can possibly see. Normal operation does not includeDetailed design
cargo tree --invert --package clap@4.5.8
Rendering features
Rendering deps
Only show dependencies in verbose mode.
Some important notes
Downloading the crate from any Cargo compatible registry
The
cargo info
command will download the crate from any Cargo compatible registry. It will then extract the information from theCargo.toml
file and display it in the terminal.If the crate is already in the local cache, it will not download the crate again. It will get the information from the local cache.
Pick the correct version from the workspace
When executed in a workspace directory, the cargo info command chooses the version that the workspace is currently using.
If there's a lock file available, the version from this file will be used. In the absence of a lock file, the command attempts to select a version that is compatible with the Minimum Supported Rust Version (MSRV). And the lock file will be generated automatically.
The following hierarchy is used to determine the MSRV:
Prior art
NPM
npm has a similar command called
npm info
.For example:
Poetry
Poetry has a similar command called
poetry show
.For example:
insta-stable
As @weihanglo mentioned in #14141 (comment), commands that shadow third-party commands tend to be insta-stabilized to avoid an intermediate period where users can't access the third-party command (built-ins get priority) nor the built-in command (requires nightly)
For the cargo-info command, there are two commands that this would shadow
We might be able to get away with having this unstable but starting from the assumption of insta-stabilization.