Open efung opened 9 months ago
Hi @efung ! Thanks for this.
I am off for a bit but will have a look in the next couple of weeks
I have done a couple of tests but will need to do more and most likely modify slightly this PR. It might take a few days.
The first issue I see is that dbt
can now also mean the dbt Cloud CLI, which is not built on Click, so, in that case, the completion fails. We'll need to have a mechanism to know if the current dbt
is dbt-core or the dbt Cloud CLI
I also want to test the performance a bit. The first tests I did on my machine were quite slow (~1 sec to return completion results), whereas the (incomplete) current version returns results immediately.
I just raised an issue in dbt-core about the performance hit of this approach and whether it can be fixed on the Core side
What
Integrate the output of the Click shell completion script into this one. This gives this script completion for commands and parameters, while preserving the previous functionality.
Resolves #20
How
I ran
_DBT_COMPLETE=bash_source dbt
and then added it to anelse
block in the check that looks for the selector flag. In addition, since this introduces a dependency ondbt
on this script, I added a check for dbt to bail out early if it's not actually installed or available.Sample shell transcript
Testing
I'm using dbt 1.5.2 on macOS 14.3. The dbt version shouldn't matter, as the completion uses the current dbt.