]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
manager: pkg: rpm: completion files for kresctl utility
authorAleš Mrázek <ales.mrazek@nic.cz>
Fri, 30 Sep 2022 12:02:36 +0000 (14:02 +0200)
committerAleš Mrázek <ales.mrazek@nic.cz>
Tue, 10 Jan 2023 18:57:13 +0000 (19:57 +0100)
distro/pkg/rpm/knot-resolver.spec
etc/meson.build
manager/shell-completion/kresctl.bash [new file with mode: 0644]
manager/shell-completion/kresctl.fish [new file with mode: 0644]

index 7edcfe3f788a869d55eecb00fc0be1a95fa05a32..11b7c98e69dbaade40482f972ac2faa87fce4739 100644 (file)
@@ -229,6 +229,9 @@ mv %{buildroot}/%{_datadir}/doc/%{name}/* %{buildroot}/%{_pkgdocdir}/
 pushd manager
 %py3_install
 install -m 644 -D etc/knot-resolver/config.yml %{buildroot}%{_sysconfdir}/knot-resolver/config.yml
+install -m 644 -D shell-completion/kresctl.bash %{buildroot}%{_datarootdir}/bash-completion/completions/kresctl
+install -m 644 -D shell-completion/kresctl.fish %{buildroot}%{_datarootdir}/fish/vendor_completions.d/kresctl.fish
+
 popd
 
 %pre
@@ -381,6 +384,8 @@ fi
 %{_sysconfdir}/knot-resolver/config.yml
 %{_unitdir}/knot-resolver.service
 %{_bindir}/kresctl
+%{_datarootdir}/bash-completion/completions/kresctl
+%{_datarootdir}/fish/vendor_completions.d/kresctl.fish
 
 %changelog
 * {{ now }} Jakub Ružička <jakub.ruzicka@nic.cz> - {{ version }}-{{ release }}
index b2e250b9f2c2e9ad2faae433cc145838c5a93b26..2fbacf640cc6c6c4f2d7007e365cd731226eb6ce 100644 (file)
@@ -27,11 +27,8 @@ if install_root_keys
   )
 endif
 
-
 subdir('config')
 
-subdir('shell-completion')
-
 install_data(
   sources: etc_files,
   install_dir: etc_dir
diff --git a/manager/shell-completion/kresctl.bash b/manager/shell-completion/kresctl.bash
new file mode 100644 (file)
index 0000000..7363913
--- /dev/null
@@ -0,0 +1,22 @@
+#/usr/bin/env bash
+
+# completion function for the kresctl
+_kresctl_completion() {
+    local cur prev opts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+    # get options
+    opts=$(kresctl completion --bash "${COMP_WORDS}")
+
+    if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
+    COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+    return 0
+    fi
+
+    return 0
+}
+
+# use the bash default completion for other arguments
+complete -o filenames -o nospace -o bashdefault -F _kresctl_completion kresctl
\ No newline at end of file
diff --git a/manager/shell-completion/kresctl.fish b/manager/shell-completion/kresctl.fish
new file mode 100644 (file)
index 0000000..8fc75a8
--- /dev/null
@@ -0,0 +1,6 @@
+function __fish_git
+    set -l args (commandline -pco)
+    eval command kresctl $args
+end
+
+complete -c kresctl -a '(_kresctl_completion)' -f
\ No newline at end of file