Skip to content

Commit

Permalink
Create openqa-cli-bash-completion package
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
b10n1k committed Dec 5, 2024
1 parent a0c5dc7 commit 693ecc7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env bash

_openqa_cli_completions() {
local cur prev subcommands main_options api_options archive_options monitor_options schedule_options
cur="${COMP_WORDS[COMP_CWORD]}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env zsh
#compdef openqa-cli

_openqa_cli_completions() {
local curcontext="$curcontext" state line
Expand Down Expand Up @@ -62,10 +62,10 @@ _openqa_cli_completions() {
_arguments '*:option:->options' $main_options $archive_options
;;
monitor)
_arguments '*:option:->options' $main_options $archive_options
_arguments '*:option:->options' $main_options $monitor_options
;;
schedule)
_arguments '*:option:->options' $main_options $archive_options
_arguments '*:option:->options' $main_options $schedule_options
;;
*)
_values 'subcommand' api archive monitor schedule
Expand Down
23 changes: 23 additions & 0 deletions dist/rpm/openQA.spec
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,20 @@ Use this package to install munin scripts that allow to monitor some openQA
statistics.
%endif

%package client-bash-completion
Summary: Bash Completion for %{name}
Requires: bash-completion
Supplements: (%{name}-client and bash)

%description client-bash-completion
The official bash completion script for openqa-cli.

%package client-zsh-completion
Summary: Zsh Completion for %{name}
Supplements: (%{name}-client and zsh)

%description client-zsh-completion
The official zsh completion script for openqa-cli.

%prep
%setup -q
Expand Down Expand Up @@ -408,6 +422,10 @@ install -m 644 contrib/munin/config/minion.config %{buildroot}/%{_sysconfdir}/mu
install -m 755 contrib/munin/utils/munin-mail %{buildroot}/%{_datadir}/openqa/script/munin-mail
%endif

# completion
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}/zsh/site-functions/_openqa-cli

cd %{buildroot}
grep -rl %{_bindir}/env . | while read file; do
sed -e 's,%{_bindir}/env perl,%{_bindir}/perl,' -i $file
Expand Down Expand Up @@ -673,6 +691,11 @@ fi
%files devel
%endif

%files client-bash-completion
%{_datadir}/bash-completion/completions/openqa-cli
%files client-zsh-completion
%{_datadir}/zsh/site-functions/_openqa-cli

%files common
%dir %{_datadir}/openqa
%{_datadir}/openqa/lib
Expand Down
10 changes: 3 additions & 7 deletions docs/UsersGuide.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -963,13 +963,9 @@ without needing to install openQA itself. Call `openqa-cli --help` for help.
The sub-commands provide further help, e.g. `openqa-cli api --help` contains
a lot of examples.

`openqa-cli` supports auto completion for `bash` and `zsh`.
If you use `bash` run or add the line below on your `.bashrc` profile.

[source,sh]
----
source openqa-cli-completion.bash
----
`openqa-cli` supports auto completion for `bash` and `zsh` with openSUSE/SLE.
We distribute two packages `openQA-client-bash-completion` and
`openQA-client-zsh-completion` as part of openQA-client.

This section focuses on particular API use-cases. Checkout the
<<Client.asciidoc#client,openQA client>> section for further information about
Expand Down

0 comments on commit 693ecc7

Please sign in to comment.