Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zsh completion is broken #57

Closed
jmcantrell opened this issue Nov 24, 2022 · 11 comments · Fixed by #103
Closed

zsh completion is broken #57

jmcantrell opened this issue Nov 24, 2022 · 11 comments · Fixed by #103

Comments

@jmcantrell
Copy link

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.

@almazgaliev
Copy link
Contributor

@jmcantrell this is clap bug , checkout here

@zUnixorn
Copy link

zUnixorn commented Feb 28, 2023

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.

@oberblastmeister
Copy link
Owner

@jmcantrell @almazgaliev @zUnixorn I updated clap in #78. Does this fix the issue?

@jmcantrell
Copy link
Author

@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?

@jmcantrell
Copy link
Author

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

@oberblastmeister
Copy link
Owner

I wonder if we should just drop the optional command, and just do trash put.

@jmcantrell
Copy link
Author

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.

@jordan-bravo
Copy link

+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

@nahoj
Copy link

nahoj commented Sep 20, 2023

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.

@stelcodes
Copy link
Contributor

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.

@Rydwxz
Copy link

Rydwxz commented Jul 24, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants