[buildozer] Add ability to print separators in output
Sometimes we want to print out multiple fields in print commands. If any of those fields are a list, it causes the number of columns to be variable, and it's kind of hard to parse things out. This also applies to when arrays are flattened. If there is a space in any of the elements, we can't tell one element from multiple elements. This patch allows us to specify how things should be printed out.
Also added a simple integration test that passed with bazel test edit/... . Lemme know if there's a different place to write those integration style tests, as I didn't see anything.
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
:memo: Please visit https://cla.developers.google.com/ to sign.
Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.
What to do if you already signed the CLA
Individual signers
- It's possible we don't have your GitHub username or you're using a different email address on your commit. Check your existing CLA data and verify that your email is set on your git commits.
Corporate signers
- Your company has a Point of Contact who decides which employees are authorized to participate. Ask your POC to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the Google project maintainer to go/cla#troubleshoot (Public version).
- The email used to register you as an authorized contributor must be the email used for the Git commit. Check your existing CLA data and verify that your email is set on your git commits.
- The email used to register you as an authorized contributor must also be attached to your GitHub account.
I should be in the fb CLA org now.
@googlebot One more once
CLAs look good, thanks!
Thanks!
(sorry, I'll be on vacation for a few days)
I'd lean towards json if that's what we'd want to do as it's a little more universally parsable. I was actually toying with just taking the normal protobuf objects and marshaling them with the json marshaler instead, but it seems like maybe the protobuf object has some internal details and that like that get a bit messy (e.g. I think there was a 'bazel_quoted_string' object or something like that at one point).
Holy cow I let this sit for a long time. @laurentlb ?
@vladmos, what do you think?
I think it would be more valuable to have a JSON output. The separators flags look like a partial workaround and might not be enough (separators might be ambiguous unless we also have proper escaping of the content).
Possibly a command buildozer print_json or a flag to select json output
Yeah, I think something like --json should work. The initial concern was that for large changes, you can't really read iteratively (I'm using this in a tool that outputs a fair chunk of data), but that may be negligible. Should this just be the protobuf format, or something different?
I feel like using a specific format (e.g. json) is better than providing multiple flags for different types of separators. However if there'll be more than two formats in the future (current and "json") I'd use an enum flag (--format=json) instead of a boolean (--json).
Sounds good. I'll try to set aside some time to implement that in the next couple of weeks.
Added in a --output_format field (can rename if desired), added a few more tests, and removed the extra flags I had before. This now just prints out the json proto format.