-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
Add a zsh completion file (automatically generated) #1712
base: dev
Are you sure you want to change the base?
Conversation
In a testing directory, I have copied the appropriate files in I'm ending up with the following error: python3 doc/generate_zsh_completion.py
Traceback (most recent call last):
File "/root/apps/doc/generate_zsh_completion.py", line 720, in <module>
main()
File "/root/apps/doc/generate_zsh_completion.py", line 73, in main
output += make_category(key, value)
File "/root/apps/doc/generate_zsh_completion.py", line 159, in make_category
output += make_action(action, action_details).replace("COMMAND", category_name)
File "/root/apps/doc/generate_zsh_completion.py", line 223, in make_action
args = make_argument_list(action_map, spaces)
File "/root/apps/doc/generate_zsh_completion.py", line 273, in make_argument_list
if argument_details["nargs"] == "+":
KeyError: 'nargs' |
Ah sorry, I made some modifications after running the linters and I left a few bugs. I tested it and it should be working now. |
Thank you so much, it is so great. :) Upon testing everything:
The following completions seem broken, though they all fit the same pattern: it looks like they do not have any args, only flags.
For reference, here is an example output: yunohost log list -
--limit
--with-details
--with-suboperations
-l
-d
-s
-- Maximum number of operations to list (default to 50)
-- Show additional infos (e.g. operation success) but may significantly increase command tim
-- Include metadata about operations that are not the main operation but are sub-operations
--limit
--with-details
--with-suboperations
-l
-d
-s
-- Maximum number of operations to list (default to 50)
-- Show additional infos (e.g. operation success) but may significantly increase command tim
-- Include metadata about operations that are not the main operation but are sub-operations
--limit
--with-details
--with-suboperations
-l
-d
-s
-- Maximum number of operations to list (default to 50)
-- Show additional infos (e.g. operation success) but may significantly increase command tim
-- Include metadata about operations that are not the main operation but are sub-operations Everything else seems to be working, which is already a lot. ❤️ |
Thanks for testing!
I don't know how to change this default behavior, neither if we want to change it. Regarding the other points:
Default behavior of zsh.
The documentation says you can use both, but it is indeed redundant for completion.
I missplelled the command.
I don't know how to retrieve the list of actions. Is there a function to list them? Or if it's a fixed list, I can add the list of choices to
I don't know how to retrieve the list of allowed keys. Same as above, is there a function to get this list?
I can add a flag in
Sometimes you want to install the same app twice, but I agree it can be confusing.
I didn't find a way of completing the next word depending on a previous one, in this case we need to know which app was given in the first argument to know which file to read. But it would be great to be able to do that.
Same as above. Also, for |
arguments: | ||
-h: | ||
full: --help | ||
help: Show this help message and exit | ||
--version: | ||
help: Display YunoHost packages versions | ||
action: callback | ||
callback: | ||
method: yunohost.utils.packages.ynh_packages_version | ||
return: true | ||
--output-as: | ||
help: Output result in another format | ||
choices: | ||
- json | ||
- plain | ||
- none | ||
--debug: | ||
help: Log and print debug messages | ||
action: store_true | ||
--quiet: | ||
help: Don't produce any output | ||
action: store_true | ||
--timeout: | ||
help: Number of seconds before this command will timeout because it can't acquire the lock (meaning that another command is currently running), by default there is no timeout and the command will wait until it can get the lock | ||
type: int | ||
|
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.
Hmmm I'm confused about this ... I understand that you need some declarative way of finding about these for the zsh autocompletion, but I doubt that moulinette
really does handle these ? It's gonna be pretty confusing when debugging the action map later ... Also I see that you have a GLOBAL_ARGUMENTS
which kinda hard-code those in generate_zsh_completion.py
so i'm confused x_X
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.
Hey, thanks for reviewing. This section was in the actionsmap before and it was removed. I didn't test with moulinette
actually. I let the GLOBAL_ARGUMENTS
in the code in case the section is missing in actionsmap, which can happen if the actionsmap file is still an old version. I don't know what's best... I think having the arguments in the _global
section in actionsmap makes is easier to update them because they are all together. But if it is not working with moulinette
we can remove the section.
Regarding auto-completing the
It seems that titus is more pointing the issue of rendering : each flag is displayed on a newline instead of all available flags on a single line, plus the output is duplicated/triplicated |
Ah ok, I also have this problem sometimes but it disappear when I start a new session of |
Hey, I just realized this was never merged. It's working fine on my server, what else is needed to merge it? |
I will test it on my setup and make comments afterwards. Anyways we might want to prevent the code duplication with the bash completion autogeneration code. |
Great! Let me know if I can help. |
The problem
There is no auto-completion suggestions for ZSH.
Solution
Follow up on PR #1034.
Add auto-completion to ZSH, by generating that completion file from
share/actionsmap.yml
As
yunohost
needs to be called withsudo
, completion may ask for password to autocomplete.PR Status
How to test
Run the script with:
It will create a file
yunohost_zsh_completion
in thedoc
folder.Move and rename the created file to
/usr/local/share/zsh/site-functions/_yunohost
(or/usr/share/zsh/vendor-completions/_yunohost
, that is where yunohost installation will install it).Restart zsh to test the completions.