dbt-labs / dbt-completion.bash

Adds autocompletion to the dbt CLI
https://www.getdbt.com/
Apache License 2.0
116 stars 29 forks source link

Add exposures, metrics and selectors for ZSH #13

Closed b-per closed 2 years ago

b-per commented 2 years ago

Changes to the ZSH completion to accommodate the following changes:

christineberger commented 2 years ago

Hey @b-per!

I'm going to list out any questions / feedback I have in a single comment here:

General questions, likely no changes needed:

  1. When I type dbt r<tab> or dbt t<tab>, is there functionality built in to bring up all commands which start with the letter? I notice that it does make the list smaller, but the list it retrieves doesn't seem to match up totally with the letter I've typed:

    Screen Shot 2022-04-22 at 3 53 56 PM Screen Shot 2022-04-22 at 3 54 20 PM Screen Shot 2022-04-22 at 3 54 41 PM
  2. I know this isn't in the tests, but when I do something like dbt build <tab> or dbt run <tab>, I get a weird autofill:

    Screen Shot 2022-04-22 at 3 57 42 PM

    I think that I would expect nothing here if it isn't supposed to do anything.

Here's a checklist I made for everything else:

[x] dbt <TAB> [x] dbt --<TAB> [x] dbt ls --<TAB> [x] dbt run --<TAB> [x] dbt test --<TAB> [x] dbt build --<TAB> [x] dbt docs --<TAB> [x] dbt docs <TAB>

--- These possibly hold up merging this - The below aren't working for me. Here's a loom [ ] dbt xxx --select source:<TAB> [ ] dbt xxx --select tag:<TAB> [ ] dbt xxx --select metrics:<TAB> [ ] dbt xxx --select exposures:<TAB> [ ] dbt xxx --select config.materialized:view [ ] dbt xxx --select state:modified [ ] dbt xxx --selector <TAB> [ ] dbt xxx --select fct_<TAB> [ ] dbt xxx --select <package_name>.<TAB> [ ]dbt run --models fct_<TAB> [ ]dbt ls --select fct_<TAB> [ ] dbt xxx --select <TAB> <TAB> [ ] dbt xxx --select <TAB>,<TAB>

b-per commented 2 years ago

Thanks @christineberger for checking the PR!

For 1. , this is the default behaviour of ZSH completion. When you type dbt d it is actually looking at all the dbt commands that contain (and not start with) d. I could check if it is possible to only get the ones starting with the letter but this behaviour has not changed since the creation of this script.

Trying to debug 2. made me find a bug (that will most likely also affect the bash version) so I pushed a change to call python3 instead of python. I don't think that your issue was related to that.

2 questions:

I couldn't reproduce the dbt build \'metrics\' error. Saying so, there is a known limitation when doing dbt run/test/build <TAB> (see the Cons part in https://github.com/dbt-labs/dbt-completion.bash/pull/7). It will display the list of models even if it is not valid. Back when I created the original script I couldn't find a way to get around it.

wasilaq commented 2 years ago

Finding and selecting models seem to be all that's working on my end. See my checklist below. I'm using oh-my-zsh and have version 1.0.3 of dbt-snowflake installed via pip3.

[ ] dbt [ ] dbt -- [ ] dbt ls -- [ ] dbt run -- [ ] dbt test -- [ ] dbt build -- [ ] dbt docs -- [ ] dbt docs

[ ] dbt xxx --select source: [ ] dbt xxx --select tag: [ ] dbt xxx --select metrics: [ ] dbt xxx --select exposures: [ ] dbt xxx --select config.materialized:view [ ] dbt xxx --select state:modified

[ ] dbt xxx -e [ ] dbt xxx --select ,

[x] dbt xxx --select [x] dbt xxx -s [x] dbt xxx --select fct [x] dbt xxx -s fct [x] dbt xxx --select . [x] dbt xxx -s . [x] dbt run --models fct [x] dbt ls --select fct [x] dbt ls -s fct_ [x] dbt xxx --select [x] dbt xxx --exclude

b-per commented 2 years ago

Thanks for the troubleshooting @wasilaq ! For the record, the behaviour was due to the bash completion being activated for zsh. Removing source ~/.dbt-completion.bash from .zshrc properly activated the "true" zsh completion