-
Notifications
You must be signed in to change notification settings - Fork 209
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 bash and zsh completion scripts for openqa-cli #6063
base: master
Are you sure you want to change the base?
Conversation
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.
The only thing I don't like is the duplication. We would have the parameters now in four places:
- https://github.com/os-autoinst/openQA/blob/master/lib/OpenQA/CLI/api.pm#L21
- https://github.com/os-autoinst/openQA/blob/master/lib/OpenQA/CLI/api.pm#L119
- And now in the two completion scripts
There is a solution for that, but it is a bigger change, not sure if we want that here.
I wrote a program that can create pod and completion scripts from a YAML file.
The openqa-cli code could also read the YAML file, so we would only have the parameters in one place.
But it would be a new dependency, at least for developers.
(One cool thing is that it can generate completion with descriptions also for bash, with a trick)
I could at least post a proof of concept.
https://gist.github.com/perlpunk/b0d9fe14f3c877f28d8af3db6be28c70 |
awesome and thanks for taking the time for the proof of concept. |
This comment was marked as resolved.
This comment was marked as resolved.
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.
It is not nice that we not only introduce one more place where we specify arguments but even two. Ideally we have a single source of truth. That would of course complicate things. Maybe we can make it so there's at least just one additional place where we specify arguments.
The code that does the argument parsing definitely needs to state in a comment that one also has to change these files when adding new parameters or changing help texts.
23714aa
to
298cf29
Compare
This comment was marked as resolved.
This comment was marked as resolved.
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.
Considering that @perlpunk already provided a proof of concept to reduce duplication with #6063 (comment) we should follow that approach
dc3d9dc
to
f75305f
Compare
6028003
to
95f0df9
Compare
a37aad3
to
ca87c8a
Compare
ca87c8a
to
73cf032
Compare
completion/openqa-cli-completion.zsh
Outdated
'--help[Show help message]' | ||
'--host[Target host, defaults to http://localhost]' | ||
'--o3[Set target host to https://openqa.opensuse.org]' | ||
'--osd[Set target host to http://openqa.suse.de]' |
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.
'--osd[Set target host to http://openqa.suse.de]' | |
'--osd[Set target host to https://openqa.suse.de]' |
completion/openqa-cli-completion.zsh
Outdated
'--poll-interval[Specifies the poll interval in seconds]' | ||
) | ||
schedule_options=( | ||
'--monitor[it until all jobs are done/cancelled and return non-zero exit code if at least on job has not passed/softfailed]' |
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.
Is the help message imply Monitor? Like this:
'--monitor[it until all jobs are done/cancelled and return non-zero exit code if at least on job has not passed/softfailed]' | |
'--monitor[Monitor it until all jobs are done/cancelled and return non-zero exit code if at least on job has not passed/softfailed]' |
60b29ee
to
703167e
Compare
I tried out the sub-packages. From within
and found |
I wrote in #6063 (comment):
Those files need to be there, as files, not directories. When you hit tab in bash, it looks into Also I showed you the example for git-subrepo before. We looked at the output for
Simply look at those files and think about what the files should look like for |
703167e
to
f5f50da
Compare
693ecc7
to
d35e888
Compare
* Allow static completion of the openqa-cli * Provide full cli options for each subcommand * Group options for each subcommand * Not help text in bash due to `compgen` function doesn't support descriptions Signed-off-by: Ioannis Bonatakis <[email protected]>
a99f139
to
d52a34f
Compare
Provide openqa-cli bash completion for openqa-cli as a package when openQA is install and bash is used. Signed-off-by: Ioannis Bonatakis <[email protected]> Signed-off-by: ybonatakis <[email protected]> Signed-off-by: Ioannis Bonatakis <[email protected]> Signed-off-by: ybonatakis <[email protected]>
d52a34f
to
b354e72
Compare
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.
Latest changes look good but please keep in mind that the major issue is still #6063 (review)
@@ -125,6 +125,17 @@ install-generic: | |||
ln -s ../postgresql.service "$(DESTDIR)"/usr/lib/systemd/system/openqa-scheduler.service.requires/postgresql.service | |||
install -d -m 755 "$(DESTDIR)"/usr/lib/systemd/system/openqa-websockets.service.requires | |||
ln -s ../postgresql.service "$(DESTDIR)"/usr/lib/systemd/system/openqa-websockets.service.requires/postgresql.service | |||
install -D -m 644 contrib/completions/openqa-cli-completion.bash "$(DESTDIR)"/usr/share//bash-completion/completions/openqa-cli | |||
install -D -m 644 contrib/completions/openqa-cli-completion.zsh "$(DESTDIR)"/usr/share/zsh/site-functions/_openqa-cli | |||
if [ "$(SHELL)" = "/bin/bash" ] || [ "$(SHELL)" = "/usr/bin/bash" ]; then \ |
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 wouldn't add anything to a user's bashrc/zshrc by default when doing make install
.
And if they have bash-completion installed, it shouldn't be necessary anyway. Same for zsh.
compgen
function doesn't support descriptions