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

refactor!: produce JSON output when --porcelain is provided in rocks search #27

Merged
merged 1 commit into from
Jun 30, 2024

Conversation

vhyrro
Copy link
Contributor

@vhyrro vhyrro commented Jun 30, 2024

This PR extends (and is based) on the changes made in #26. Running rocks search --porcelain will now also produce JSON output.

Comment on lines +47 to 58
if data.porcelain {
println!("{}", serde_json::to_string(&rock_to_version_map)?);
} else {
for (key, versions) in rock_to_version_map.into_iter().sorted() {
let mut tree = StringTreeNode::new(key.to_owned());

println!("{}", tree.to_string_with_format(&formatting)?);
for version in versions {
tree.push(version.to_owned());
}

println!("{}", tree.to_string_with_format(&formatting).unwrap());
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: this could be rewritten as a match statement for utmost clarity I guess, but I'm impartial to cosmetics like this. Thoughts are welcome.

Base automatically changed from push-mxlyqvnprzmm to master June 30, 2024 18:06
@vhyrro vhyrro merged commit 54063c6 into master Jun 30, 2024
4 of 6 checks passed
@vhyrro vhyrro deleted the json-output branch June 30, 2024 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants