Watson icon indicating copy to clipboard operation
Watson copied to clipboard

can someone advice why bash completion does not work?

Open alfonz19 opened this issue 2 years ago • 9 comments

In instalation text:

If you use a Bash-compatible shell, you can install the watson.completion file from the source distribution as /etc/bash.completion.d/watson - or wherever your distribution keeps the Bash completion configuration files. After you restart your shell, you can then just type watson on your command line and then hit TAB to see all available commands.

First pip install --user td-watson then ... file from source distribution? Where, what?

Ok, so I went with development version, installed it, copied bash completion as instructed, I trying to debug why it's not working I just added logging:

_watson_completionetup() {
  echo 'registered'>>/tmp/watson_setup

and

_watson_completion() {
    local IFS=$'
'
    COMPREPLY=( $( env COMP_WORDS="${COMP_WORDS[*]}" \
                   COMP_CWORD=$COMP_CWORD \
                   _WATSON_COMPLETE=complete $1 ) )
    echo "$COMPREPLY" >> /tmp/watson_setup
    return 0
}

restarted bash, and I see, that 'registered' appears in file as expected, but COMPREPLY is always logged as empty string. I'm no bash expert, but I cannot see in completion script neither any list of supported actions nor call to watson to get one.

what am I doing wrong?

alfonz19 avatar Dec 24 '22 11:12 alfonz19

Second, Bash completion doesn't work with Watson 2.1.0 for me. I have it in ~/.local/share/bash-completions/completions/watson, and it used to work on the previous version.

I confirmed just now that the completion file hasn't changed in a few years, so I'm wondering if this is due to the recent click version bump...

siiky avatar Dec 30 '22 15:12 siiky

what is "click version bump?"

alfonz19 avatar Dec 30 '22 17:12 alfonz19

This is what I mean: https://github.com/TailorDev/Watson/commit/b2068f64600d53221270c864abd136ac0254ae2d.

click is the library used for the CLI (easier to generate help text, autocompletion, etc).

siiky avatar Jan 03 '23 22:01 siiky

I confirm this. Autocompletion doesn't work.

Issam2204 avatar Jan 07 '23 12:01 Issam2204

Tab completion is broken for me, too, though I'm fairly sure it was working until recently (and definitely after May 2022).

bewuethr avatar Jan 10 '23 15:01 bewuethr

Same behavior in my environment. Would be great if I can use the autocomplete again in the future.

toheine avatar Feb 20 '23 10:02 toheine

Confirmed that downgrading to td-watson==2.0.1 resolves the bash completion. A couple notes regarding this process

  1. brew only has the latest, so you have to resort to pip-install on a Mac
  2. pip still pulls click>8 by default, so I had to override that with the old spec click>=7.0,<8.0 which resulted in 7.1.2

addisonklinke avatar Mar 02 '23 14:03 addisonklinke

Confirmed that downgrading to td-watson==2.0.1 resolves the bash completion. A couple notes regarding this process

  1. brew only has the latest, so you have to resort to pip-install on a Mac
  2. pip still pulls click>8 by default, so I had to override that with the old spec click>=7.0,<8.0 which resulted in 7.1.2

Executed these two commands on my ubuntu to achieve downgrade of td-watson and click package, after which bash completion starts working: 1, pip install td-watson==2.0.1 2. pip install click==7.1.2

YoungMahesh avatar Oct 05 '23 05:10 YoungMahesh

Bash completion works using this previous version of the 'watson.completion' file. Just put this file to /etc/bash_completion and it will work again with the latest (2.1.0) release.

stbazsa avatar Nov 03 '23 17:11 stbazsa