buildtools icon indicating copy to clipboard operation
buildtools copied to clipboard

[buildozer] Add ability to print separators in output

Open nataliejameson opened this issue 7 years ago • 12 comments

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.

nataliejameson avatar May 17 '18 20:05 nataliejameson

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
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.

googlebot avatar May 17 '18 20:05 googlebot

I should be in the fb CLA org now.

nataliejameson avatar May 18 '18 16:05 nataliejameson

@googlebot One more once

nataliejameson avatar May 22 '18 05:05 nataliejameson

CLAs look good, thanks!

googlebot avatar May 22 '18 05:05 googlebot

Thanks!

(sorry, I'll be on vacation for a few days)

laurentlb avatar May 24 '18 17:05 laurentlb

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).

nataliejameson avatar Jun 11 '18 18:06 nataliejameson

Holy cow I let this sit for a long time. @laurentlb ?

nataliejameson avatar Nov 14 '18 01:11 nataliejameson

@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

laurentlb avatar Nov 14 '18 13:11 laurentlb

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?

nataliejameson avatar Nov 14 '18 16:11 nataliejameson

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).

vladmos avatar Dec 03 '18 18:12 vladmos

Sounds good. I'll try to set aside some time to implement that in the next couple of weeks.

nataliejameson avatar Dec 03 '18 18:12 nataliejameson

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.

nataliejameson avatar Dec 11 '18 22:12 nataliejameson