Watson icon indicating copy to clipboard operation
Watson copied to clipboard

Fix completions broken since click>=8

Open voidus opened this issue 3 years ago • 16 comments

Quoting click changelog for 8.0.0

The env var values used to start completion have changed order. The shell now comes first, such as {shell}source rather than > source{shell}, and is always required.

I think this fix warrants a 2.1.1 release, since missing completions are kind of a big deal for a lot of people. (Shamelessly generalizing from my experience)

voidus avatar May 24 '22 15:05 voidus

Having some other issues with completion:

    from watson.__main__ import cli
  File "/nix/store/0qj8zhf7pklvwcq3ix60pa3cb9vcdcly-watson-2.1.0/lib/python3.9/site-packages/watson/__main__.py", line 3, in <module>
    cli.cli()
  File "/nix/store/ali8g6rx2lj3kb15lwxkp0d2ny0dihmz-python3.9-click-8.1.3/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/nix/store/ali8g6rx2lj3kb15lwxkp0d2ny0dihmz-python3.9-click-8.1.3/lib/python3.9/site-packages/click/core.py", line 1050, in main
    self._main_shell_completion(extra, prog_name, complete_var)
  File "/nix/store/ali8g6rx2lj3kb15lwxkp0d2ny0dihmz-python3.9-click-8.1.3/lib/python3.9/site-packages/click/core.py", line 1125, in _main_shell_completion
    rv = shell_complete(self, ctx_args, prog_name, complete_var, instruction)
  File "/nix/store/ali8g6rx2lj3kb15lwxkp0d2ny0dihmz-python3.9-click-8.1.3/lib/python3.9/site-packages/click/shell_completion.py", line 49, in shell_complete
    echo(comp.complete())
  File "/nix/store/ali8g6rx2lj3kb15lwxkp0d2ny0dihmz-python3.9-click-8.1.3/lib/python3.9/site-packages/click/shell_completion.py", line 291, in complete
    completions = self.get_completions(args, incomplete)
  File "/nix/store/ali8g6rx2lj3kb15lwxkp0d2ny0dihmz-python3.9-click-8.1.3/lib/python3.9/site-packages/click/shell_completion.py", line 273, in get_completions
    return obj.shell_complete(ctx, incomplete)
  File "/nix/store/ali8g6rx2lj3kb15lwxkp0d2ny0dihmz-python3.9-click-8.1.3/lib/python3.9/site-packages/click/core.py", line 2397, in shell_complete
    results = self._custom_shell_complete(ctx, self, incomplete)
  File "/nix/store/0qj8zhf7pklvwcq3ix60pa3cb9vcdcly-watson-2.1.0/lib/python3.9/site-packages/watson/autocompletion.py", line 51, in get_project_or_task_completion
    tok.startswith("+") for tok in args + [incomplete]
TypeError: unsupported operand type(s) for +: 'Argument' and 'list'

so I'll mark this WIP for now

voidus avatar May 24 '22 23:05 voidus

Thanks you for this @voidus :pray: Keep it up :muscle:

jmaupetit avatar May 25 '22 09:05 jmaupetit

Okay this was a bit of a ride, I ended up mostly rewriting the completion.

I started implementing it while respecting the multi-word features (that is, being able to enter watson add my cool project +and a tag +another tag without putting quotes, but there are so many edge cases it's crazy.

Finally, I ended up ignoring it, because it was not consistently supported anyways. Both as a developer and a user, I would advise to officially drop that feature.

But that's not the point here. It would be great if you could have a look and let me know what you think, I ended up changing more than I planned.

voidus avatar Jun 06 '22 12:06 voidus

squashed the two commits

voidus avatar Jun 06 '22 12:06 voidus

@jmaupetit could you have a look please?

voidus avatar Jun 13 '22 22:06 voidus

@voidus @jmaupetit any chance to get this in?

soltysh avatar Nov 28 '22 11:11 soltysh

I also added this patch to https://github.com/nixos/nixpkgs so I have it installed cleanly, so I'm not in a personal rush but I'm very much up to working in any requested changes.

voidus avatar Nov 28 '22 11:11 voidus

Rebased on main, no change was needed

voidus avatar Nov 28 '22 11:11 voidus

I've just downloaded this locally and it looks like it's fixing the problems described in #477.

soltysh avatar Nov 28 '22 15:11 soltysh

Works fine (and finally again) for me. Completions are hard, but very useful to me. Please include in upstream!

sluedecke avatar Dec 07 '22 07:12 sluedecke

@jmaupetit Any chance to review and merge this in?

Igetin avatar Dec 07 '22 07:12 Igetin

If jmaupetit isn't available, maybe @willdurand could you have a look? This seems to affect multiple people.

voidus avatar Dec 08 '22 07:12 voidus

I will add myself to the list of affected people who would like to see this merged. Happy New Year!

amsesk avatar Jan 17 '23 22:01 amsesk

@voidus Thank you very much! Used your version of watson.zsh-completion and the completion is working again!

Please finish the PR.

UPD: Works with errors. But works. Waiting for this PR

ivan-volnov avatar Mar 27 '23 07:03 ivan-volnov

FYI, I've stopped using watson. I'd still be happy to tweak this PR if it needs additional work but I won't push for it to be merged.

voidus avatar Apr 23 '23 13:04 voidus

I’ve been using this branch directly, since it isn’t merged into master yet. I’ve done this for months now and noticed no problems with it.

FYI, I've stopped using watson. I'd still be happy to tweak this PR if it needs additional work but I won't push for it to be merged.

Off-topic, but I’m curious: did you switch to some other tool for time tracking? Watson does its job, but I’d rather use something that is actually maintained.

Igetin avatar Apr 23 '23 16:04 Igetin