Formatting for output of locate-project#8683
Formatting for output of locate-project#8683dtolnay wants to merge 6 commits intorust-lang:masterfrom
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? |
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.