Skip to content
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

Command-line-friendly version of locate-project #8009

Closed
sollyucko opened this issue Mar 16, 2020 · 2 comments · Fixed by #8707
Closed

Command-line-friendly version of locate-project #8009

sollyucko opened this issue Mar 16, 2020 · 2 comments · Fixed by #8707
Labels
A-console-output Area: Terminal output, colors, progress bar, etc. A-json-output Area: JSON message output C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-locate-project

Comments

@sollyucko
Copy link

Describe the problem you are trying to solve
cargo locate-project and cargo metadata both return JSON output, which may be easiest when writing programs to parse it, but it is much more difficult to use in simple shell scripts.

Describe the solution you'd like
A --output-format flag or similar might be the neatest way to solve this. For example, cargo locate-project --output-format minimal (or something similar) would return just the path to Cargo.toml. It could also be formatted as root path or something similar, allowing the use of grep + cut for parsing, and would be more generalizable and allow for future extension locate-project.

Additionally, this sort of flag could also be extended to other commands and formats, as needed.

@sollyucko sollyucko added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Mar 16, 2020
@sollyucko
Copy link
Author

As a workaround, for now I'm using jq, as cargo locate-project | jq -r '.root'.

@ehuss ehuss added A-console-output Area: Terminal output, colors, progress bar, etc. A-json-output Area: JSON message output Command-locate-project labels Mar 24, 2020
@dtolnay
Copy link
Member

dtolnay commented Sep 6, 2020

Submitted a PR for this. #8683

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-console-output Area: Terminal output, colors, progress bar, etc. A-json-output Area: JSON message output C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-locate-project
Projects
None yet
3 participants