zsh completion is broken
jmcantrell opened this issue ยท 11 comments
When completing with any input on zsh, all I get is the following error:
_arguments:comparguments:327: doubled rest argument definition: *::: :->trashy
I'm using the aur version on arch.
@jmcantrell this is clap bug , checkout here
Clap has now fixed the underlying issue and also just made a new release. Bumping the version of clap to v4.1.8 could fix this issue then.
@jmcantrell @almazgaliev @zUnixorn I updated clap in #78. Does this fix the issue?
@oberblastmeister I only tested zsh, but I replaced /usr/share/zsh/site-functions/_trash
with the completion script generated by trashy on master and I still get the same error. Does it work for you?
I've been digging through this project's code and clap's for a bit and I'm thinking that this might not be a solvable problem on clap's end. The way trashy is using the parser now (as I understand it) is that it's flattening the main commands args into the parser along with the put command's args, both of those sets of args expect varying number of trailing arguments. The main command is looking for 0 or 1 command names whereas the put command is looking for 0 or more paths. Zsh, and I'm pretty sure the other supported shells, do not support this, which means that there will not be a way to generate a correct completion script.
I'm looking at the git example in clap's docs (https://docs.rs/clap/latest/clap/_derive/_cookbook/git_derive/index.html) to see how they handle this case (git stash, where push is the default command).
I wonder if we should just drop the optional command, and just do trash put
.
Personally, that's the interface I want, and if this were a brand new project it would be what I would push for. The only reason I didn't suggest it is because it's a breaking change, and it's one of the features mentioned in the readme.
+1 to this problem.
I'm getting the error when trying to use tab completion, regardless of whether I use the command trash
or trash put
.
Steps to reproduce
Type trash
then press Tab.
or
Type trash put
then press Tab.
Expected result
Tab completion should show the files and folders in current directory.
Actual result
The following error is displayed:
_arguments:comparguments:327: doubled rest argument definition: *::: :->trashy
Additional info
OS: NixOS
Shell: Zsh
Terminal: Kitty
I wonder if we should just drop the optional command, and just do
trash put
.
Sounds very reasonable. Any existing script that relies on trash <file>
is already very brittle, because it breaks on a file named list
.
As for interactive use, typing trash put
is less convenient, but anyone who uses it often can define an alias.
Just some user feedback, I would personally not mind at all if the subcommand was made necessary. I noticed the help/manpage generation is a bit confusing at the moment:
Help:
Usage: trash [OPTIONS] [PATHS]... [COMMAND]
Manpage:
SYNOPSIS
trashy [-c|--color] [-t|--table] [-h|--help] [-V|--version] [PATHS] [subcommands]
Notice how the subcommands
argument is positioned after the PATHS
. While technically true for the trash <path>
invocation, that's a bit confusing for new users. Making this change might make clap generate a more readable docstring.
Unfortunately completion still doesn't seem to work when trash put
is aliased in .zshrc such as alias -g del="trash put"
. I have a workaround with a script in my path which is simply trash put $1
but that doesn't seem like the ideal user experience.