tealdeer-rs / tealdeer

A very fast implementation of tldr in Rust.
https://tealdeer-rs.github.io/tealdeer/
Apache License 2.0
4.17k stars 123 forks source link

Broken `zsh` completion #137

Closed BachoSeven closed 4 years ago

BachoSeven commented 4 years ago

Hi! After installing latest tag release, attempting to complete in zsh gives the following error:

_arguments:comparguments:325: invalid argument: (-h --help -v --version --color){--color}[Controls when to use color]:when:((\n\t    always\n\t    auto\n\t    never\n        ))
_arguments:comparguments:325: invalid argument: (-h --help -v --version --color){--color}[Controls when to use color]:when:((\n\t    always\n\t    auto\n\t    never\n        ))
_arguments:comparguments:325: invalid argument: (-h --help -v --version --color){--color}[Controls when to use color]:when:((\n\t    always\n\t    auto\n\t    never\n        ))
dbrgn commented 4 years ago

Hm, unfortunately I'm not familiar with the zsh completion format... Are you familiar with it? Do you see what the problem is?

BachoSeven commented 4 years ago

I have written only basic completions but I will try.

The breakage is definitely due to this commit, and based on the rest of the syntax, I think it should be like this, since the new --color argument which seems to be the problem does not need the extra arguments, just like --seed-config("long-format-only" options):

--- zsh_tealdeer.orig   2020-09-04 01:22:52.766594547 +0200
+++ /usr/share/zsh/site-functions/_tldr 2020-09-04 01:23:03.139927740 +0200
@@ -25,11 +25,11 @@
    "($I -q --quiet)"{-q,--quiet}"[Suppress informational messages]"
    "($I)--config-path[Show config file path]"
    "($I)--seed-config[Create a basic config]"
-   "($I --color)"{--color}'[Controls when to use color]:when:((
+   "($I)--color[Controls when to use color]:when:((
        always
        auto
        never
-        ))'
+        ))"
    '(- *)'{-h,--help}'[Display help]'
        '(- *)'{-v,--version}'[Show version information]'
        '*:file:_files'

This fixed the issue for me.

BachoSeven commented 4 years ago

I opened a PR with the aforementioned solution, if you want to test it in zsh you just need to install it and run autoload -Uz compinit && compinit, and you should be able to see if it works(it does for me).

dbrgn commented 4 years ago

Thanks for the instructions, seems to work!