cargo icon indicating copy to clipboard operation
cargo copied to clipboard

command to get the version of a specific crate

Open wiiznokes opened this issue 6 months ago • 1 comments

Problem

I need to get the version of my crate for packaging my app in my CI. I thinks it is an important feature so it shouldn't require regular expression

Proposed Solution

maybe by extending cargo pkgid command with an option --version

Notes

This command will give you the version:

cargo pkgid | grep -oP '@\K\d+\.\d+\.\d+'

wiiznokes avatar Dec 09 '23 16:12 wiiznokes

While the version is included in the output of cargo pkgid, it wouldn't fit within that command to include the version as that is canonicalizing package ids.

We do have cargo metadata though that displays all packages for a workspace and its output is in json, requiring a tool to extract a value. We've had various requests for lookups of various fields that output to plain text. For myself, the general solution is best as each request has different needs.

There is also cargo read-manifest. iirc it is deprecated.

epage avatar Dec 10 '23 00:12 epage