-
Notifications
You must be signed in to change notification settings - Fork 2k
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
completions/trash-cli: add completions for trash-cli #9560
Conversation
Add completions for trash-cli commands: trash, trash-empty, trash-list, trash-put and trash-restore.
share/completions/trash-empty.fish
Outdated
@@ -0,0 +1,9 @@ | |||
complete -f -c trash-empty -s h -l help -d 'show help message' | |||
complete -f -c trash-empty -l print-completion -a 'bash zsh tcsh' -d 'print shell completion script' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to pass -x
here, so that bash/zsh/tcsh are the only options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your swift review.
I'm sorry for making such a mistake and I have to add one more commit to fix that.
I realize that this pr may be abnormal and I can reopen one if you want to.
Thanks. :)
Pass ``-x`` to option ``--print-complete`` so that it will forcely require an argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would request identification of the trash
executable via some means as it isn't a unique name by any means and there are several implementations in different languages and for different platforms floating around.
CHANGELOG.rst
Outdated
- ``trash`` | ||
- ``trash-empty`` | ||
- ``trash-list`` | ||
- ``trash-put`` | ||
- ``trash-restore`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you collapse these to one line ("trash
and helper utilities trash-empty
, trash-put
, ...")?
It's my fault to ignore other implementations of trash tools.
And there are relatively popular trash cli tools I found: And as for the means to identify |
No worries and your English is excellent! To be clear, I'm not asking you to add completions for other versions/implementations of You can squash the commits or I'll squash them when I'm merging. Whatever works for you. If you are only adding this one implementation of trash, you can just use the changelog line I suggested. If you are going to go down the route of adding multiple versions of trash, you can use "trash (various implementations)" or similar. To load multiple completions you can place completions for each "distribution" of trash in a function all in the same file then call the function depending on which "trash" you've identified as being installed. You don't need to do this for the specialized utilities like |
…rash-cli There are many different implementations of trash cli tools. Use some means like help message to identify excutables of different implementations.
Thanks for your patient guidance. |
share/completions/trash.fish
Outdated
if string match -qr "https://github.com/andreafrancia/trash-cli" (trash --help) | ||
__trash_by_andreafrancia | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good - you're right, this is less likely to break than --version
.
There's just one small problem: let's say tomorrow someone installs a different trash
that doesn't have --help
(so it'll print an error to stderr) or it writes --help
output to stderr for some reason. In this case, trash.fish
will print junk to the terminal because you are only capturing stdout in the subshell (trash --help)
.
Can you change this to either (trash --help 2>/dev/null)
or (trash --help >&1)
to prevent that from happening?
I can change it too but I wanted to share this with you as a learning opportunity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good except for the small issue with --help
output that I commented on above.
``trash --help`` are used to identify the excutable in trash cli completion. Some implementation may not have the ``--help`` option and therefore prints junks to stderr. Redirect stderr to /dev/null.
I should have taken the missing help option and stderr into consideration. |
Add completions for trash-cli commands: trash, trash-empty, trash-list, trash-put and trash-restore. ``trash --help`` are used to identify the executable in trash cli completion. (cherry picked from commit ce268b7)
Description
Add completions for trash-cli commands:
trash, trash-empty, trash-list, trash-put and trash-restore.
TODOs: