-
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
Formatting for output of locate-project #8683
Conversation
r? @Eh2406 (rust_highfive has picked a reviewer for you, use r? to override) |
Thanks for the PR! This definitely seems useful. Can you say more why you went with a free-form "format" option? We were thinking it might be better to use a fixed-format flag like |
I was hoping to propose a way to locate the workspace's Cargo.toml, something I needed in https://github.com/dtolnay/cargo-rm and realized the only way to get it from a script is jq or a heroic sed. For just the current crate root a new |
This PR (or some (@dtolnay As an unrelated side note: The popular |
Yea, I think I would probably prefer that. Would you be ok with making that change? |
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.
Closing in favor of #8707.
Add plain message format for locate-project Supersedes #8683, as recommended in #8683 (comment). This PR adds a flag `--message-format` to `cargo locate-project` with possible values `json` (default) and `plain`. ```console $ cargo locate-project --message-format json {"root":"/git/cargo/Cargo.toml"} $ cargo locate-project --message-format plain /git/cargo/Cargo.toml ``` Closes #8009.
This PR brings
cargo tree
's existing --format flag tocargo locate-project
.This allows scripts to select a script-friendly output representation. All the logic for interpreting such format flags already exists and is used by
cargo tree --format
. This solution is straightforwardly forward-compatible with introducing additional entries into what locate-project can produce, unlike such alternatives ascargo locate-project --output-format plain
.I like
jq
(am the third biggest contributor to it) but in 2020 we can't count on it being installed on target systems.Closes #8009.