Search code examples
documentationbazel

`bazel help` in machine readable format


Is there a way to invoke bazel help such that it outputs a machine readable format. I would like to parse all the flags that are available in Bazel and make them automatically available in ibazel so that I don't have to manually sync them every time a new bazel release comes out with different flags.

There used to be a --helpxml argument that printed things out as XML, but it seems the command line argument parser has changed and you can no longer use that. I presume there is still some way to get this, since the docs are being generated with up to date command line info. Unfortunately the "edit this page" button on the docs site 404s and I can't figure out its origin.


Solution

  • The docs for the flags are generated via this genrule, which essentially runs bazel help everything-as-html, the source of which is here.

    There are a few other options listed in that case statement, one of which being flags-as-proto which emits the flags as a base64 encoded version of the BazelFlagsProto.

    Potentially ibazel could read this in, load in the proto and pull out the data from there.