-
Notifications
You must be signed in to change notification settings - Fork 208
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. |
I would say, at least make it installable like discussed in this thread #6063 (comment) |
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
Great PR! Please pay attention to the following items before merging: Files matching
This is an automatically generated QA checklist based on modified files. |
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
@@ -0,0 +1,37 @@ | |||
#!/usr/bin/env bash |
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 still prefer a more generic directory name. We don't want to create a top level subfolder for every kind of feature we add.
I suggest either share/completion
, or we use the existing contrib
directory, so contrib/completion
.
Other opinions?
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.
contrib/completion
seems like a nice place
dist/rpm/openQA.spec
Outdated
install -Dm 0644 completion/openqa-cli-completion.bash %{buildroot}%{_datadir}/openqa/completion/openqa-cli-completion.bash | ||
install -Dm 0644 completion/openqa-cli-completion.zsh %{buildroot}%{_datadir}/openqa/completion/openqa-cli-completion.zsh |
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 think this should do it, haven't tested it yet:
install -Dm 0644 completion/openqa-cli-completion.bash %{buildroot}%{_datadir}/openqa/completion/openqa-cli-completion.bash | |
install -Dm 0644 completion/openqa-cli-completion.zsh %{buildroot}%{_datadir}/openqa/completion/openqa-cli-completion.zsh | |
install -D -m 0644 %{_sourcedir}/contrib/completion/openqa-cli-completion.bash %{buildroot}%{_datadir}/bash-completion/completions/openqa-cli | |
install -D -m 0644 %{_sourcedir}/contrib/completion/openqa-cli-completion.zsh %{buildroot}%{_datadir}/zsh/site-functions/_openqa-cli | |
# ... | |
# later | |
%files client-bash-completion | |
%{_datadir}/bash-completion/completions/openqa-cli | |
%files client-zsh-completion | |
%{_datadir}/zsh | |
* 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]>
a37aad3
to
ca87c8a
Compare
dist/rpm/openQA.spec
Outdated
@@ -419,6 +434,8 @@ done | |||
# | |||
install -D -m 644 /dev/null %{buildroot}%{_localstatedir}/log/openqa | |||
install -m 0644 %{_sourcedir}/openQA.changes %{buildroot}%{_datadir}/openqa/public/Changelog | |||
install -Dm 0644 completion/openqa-cli-completion.bash %{buildroot}%{_datadir}/bash-completion/completions/openqa-cli | |||
install -Dm 0644 completion/openqa-cli-completion.zsh %{buildroot}%{_datadir}/usr/share/zsh/site-functions/_openqa-cli |
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.
There was a reason I used %{_sourcedir}
in my suggestion.
Hint: look a little bit up in line 426 cd %{buildroot}
. At that point we are not in the source dir anymore.
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.
sorry
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.
[ 42s] + install -Dm 0644 /home/abuild/rpmbuild/SOURCEScompletion/openqa-cli-completion.bash /home/abuild/rpmbuild/BUILDROOT/openQA-4.6.1732626492.73cf032a-7440.1.x86_64/usr/share/bash-completion/completions/openqa-cli
[ 42s] install: cannot stat '/home/abuild/rpmbuild/SOURCEScompletion/openqa-cli-completion.bash': No such file or directory
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.
Apart from missing a slash, now I think _sourcedir might not be the directory we want here.
Try it out by adding the slash.
Otherwise you can just move those statements up before the cd
statement.
73cf032
to
e511759
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]>
e511759
to
b337349
Compare
compgen
function doesn't support descriptions