TailorDev / Watson

:watch: A wonderful CLI to track your time!
http://tailordev.github.io/Watson/
MIT License
2.41k stars 237 forks source link

can someone advice why bash completion does not work? #491

Open alfonz19 opened 1 year ago

alfonz19 commented 1 year ago

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?

siiky commented 1 year ago

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...

alfonz19 commented 1 year ago

what is "click version bump?"

siiky commented 1 year ago

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).

Issam2204 commented 1 year ago

I confirm this. Autocompletion doesn't work.

bewuethr commented 1 year ago

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

toheine commented 1 year ago

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

addisonklinke commented 1 year ago

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
YoungMahesh commented 9 months ago

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

  1. pip install click==7.1.2
stbazsa commented 8 months ago

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.