develwoutacause’s avatardevelwoutacause’s Twitter Archive—№ 1,363

  1. I was debugging some @bazelbuild providers today with --output starlark but found the output to be completely unreadable, so I wrote a Starlark script to format the output in a much more usable fashion. Much easier to parse in my head! gist.github.com/dgp1130/a26706cf3a85a6dcf7484591ddff41ba
    A terminal with a `bazel cquery --output starlark` command which displays all the providers for a target in a nicely formatted and indented view.
    1. …in reply to @develwoutacause
      This has been bugging me for a while and when I finally tried to write the script I discovered it was much harder than you would expect because Starlark doesn't support recursion (or even while loops), so printing recursively typed structures (such as a list of lists) is tough.
      1. …in reply to @develwoutacause
        It kinda nerd-sniped me, so I had to figure out how to do this iteratively, and came away with a manually managed stack-frame approach. Not my cleanest code, but it gets the job done. This script probably already exists somewhere, but I managed to save 30 seconds of Googling! 😎