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

feat: fetch flags from bazel help as proto #18

Merged
merged 1 commit into from
Sep 24, 2021
Merged

feat: fetch flags from bazel help as proto #18

merged 1 commit into from
Sep 24, 2021

Conversation

mattem
Copy link
Member

@mattem mattem commented Sep 7, 2021

Adds the ability to fetch all the flags from bazel help flags-as-proto.

This includes a vendored pkg/bazel/bazelisk.go file as a small tweak to the exposed API is required to pass in the stream on which to write the response.

Includes the generated flags.pb.go file so my editor was happy, I'll add a generated_file_test if this is an okay approach. (but I like the IDE with no red squiggles)

I'd like some help with line 32 in pkg/bazel/flags.go, it always raises an error, but the unmarshalled proto is fine :/

@@ -0,0 +1,600 @@
package bazel
Copy link
Member Author

Choose a reason for hiding this comment

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

This likely needs a different license header stamped in?

Copy link
Member

Choose a reason for hiding this comment

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

yeah, and/or a vendor folder like Go idiom prescribes

go.bzl Outdated
@@ -1033,10 +1033,10 @@ def deps():
)
go_repository(
name = "org_golang_x_tools",
build_directives = ["gazelle:exclude **/testdata/**/*"],
Copy link
Member Author

Choose a reason for hiding this comment

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

🦌 gazelle did this

Copy link
Contributor

Choose a reason for hiding this comment

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

Finally, Gazelle is starting to ignore testdata.

func (b *Bazel) Flags() map[string]*FlagInfo {
helpCmdBuffer := new(bytes.Buffer)

if _, err := b.RunCommand([]string{"help", "flags-as-proto"}, helpCmdBuffer); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

TODO to memoize the flags keyed on the bazel version

@mattem mattem merged commit 0b2d2a3 into main Sep 24, 2021
@mattem mattem deleted the flags_as_proto branch September 24, 2021 20:48
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.

3 participants