use .buildifier-tables.json file without specifying on CLI
We need to use a custom tables.json file with --add_tables or --tables. But it would help if we did not need to specify it on the command line each time. Some integrations such as VSCode auto-download buildifier and auto-run it.
Fixes could include:
- if .buildifier-tables.json exists in root of workspace, use it
- add config option to .buildifier.json file with the path to tables.json (and whether it is an -add_tables or --tables)
- allow buildifier-tables.json content to be embedded inside .buildifier.json
Maybe I have missed something and this is already there -- if so it would be helpful to know. Thanks for a great tool!
Just to reply and share, this is already possible. The Config struct defines all the fields for .buildifier.json. There is a AddTablesPath field, with json annotation for the name addTables. This means that "addTables": ".buildifier-tables.json" could be added to your .buildifier.json and it'll update necessary fields. Here's the struct that defines all the settings for what can go into .buildifier-tables.json.
I know this issue is a bit old, but I hope this reply helped (either for you or for people who find this in the future).
P.S. Note that there is also a TablesPath (as just tables in json), but I never use it (replacing is kinda annoying, IMO).
One thing to note, though, is that the addTables path is always interpreted as relative to the buildifier CWD, meaning, if your CWD isn't at the root of the repo, something like this breaks buildifier:
{
"AddTables": ".buildifier-tables.json"
}
Is there any known workaround to the issue with interpreting the addTables path relative to PWD rather than relative to the .buildifier.json file?