mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-06-07 10:34:44 +02:00
Upstream is very slowly and didn't merge the PR since June 2024. Closes https://gitlab.alpinelinux.org/alpine/aports/-/issues/16453
116 lines
3 KiB
Diff
116 lines
3 KiB
Diff
Patch-Source: https://github.com/scop/bash-completion/pull/766
|
|
(but test/test-cmd-list.txt removed)
|
|
---
|
|
From 2d7a7f0415158f0e5733bb259c36550fa673c3c2 Mon Sep 17 00:00:00 2001
|
|
From: archetype <burchakov.oleg@gmail.com>
|
|
Date: Sun, 26 Jun 2022 21:18:30 +0300
|
|
Subject: [PATCH] feat(doas): new completion
|
|
|
|
---
|
|
completions/Makefile.am | 1 +
|
|
completions/doas | 45 +++++++++++++++++++++++++++++++++++++++++
|
|
test/t/Makefile.am | 1 +
|
|
test/t/test_doas.py | 17 ++++++++++++++++
|
|
test/test-cmd-list.txt | 1 +
|
|
5 files changed, 65 insertions(+)
|
|
create mode 100644 completions/doas
|
|
create mode 100644 test/t/test_doas.py
|
|
|
|
diff --git a/completions/Makefile.am b/completions/Makefile.am
|
|
index 2a7a5b3adf2..f5a1829fbf2 100644
|
|
--- a/completions/Makefile.am
|
|
+++ b/completions/Makefile.am
|
|
@@ -86,6 +86,7 @@ bashcomp_DATA = 2to3 \
|
|
dmypy \
|
|
dnssec-keygen \
|
|
dnsspoof \
|
|
+ doas \
|
|
dot \
|
|
dpkg \
|
|
dpkg-source \
|
|
diff --git a/completions/doas b/completions/doas
|
|
new file mode 100644
|
|
index 00000000000..1b5abc64b19
|
|
--- /dev/null
|
|
+++ b/completions/doas
|
|
@@ -0,0 +1,45 @@
|
|
+# doas(1) completion -*- shell-script -*-
|
|
+
|
|
+_comp_cmd_doas()
|
|
+{
|
|
+ local cur prev words cword split
|
|
+ _init_completion -s || return
|
|
+
|
|
+ local i
|
|
+
|
|
+ for ((i = 1; i <= cword; i++)); do
|
|
+ if [[ ${words[i]} != -* ]]; then
|
|
+ local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
|
|
+ local root_command=${words[i]}
|
|
+ _command_offset $i
|
|
+ return
|
|
+ fi
|
|
+ [[ ${words[i]} == -@(!(-*)[uCLs]) ]] &&
|
|
+ ((i++))
|
|
+ done
|
|
+
|
|
+ case "$prev" in
|
|
+ -!(-*)u)
|
|
+ COMPREPLY=($(compgen -u -- "$cur"))
|
|
+ return
|
|
+ ;;
|
|
+ -!(-*)C)
|
|
+ _filedir
|
|
+ return
|
|
+ ;;
|
|
+ -!(-*)[Ls])
|
|
+ return
|
|
+ ;;
|
|
+ esac
|
|
+
|
|
+ $split && return
|
|
+
|
|
+ if [[ $cur == -* ]]; then
|
|
+ COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
|
|
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
|
|
+ return
|
|
+ fi
|
|
+} &&
|
|
+ complete -F _comp_cmd_doas doas
|
|
+
|
|
+# ex: filetype=sh
|
|
diff --git a/test/t/Makefile.am b/test/t/Makefile.am
|
|
index 8b6dcdcbc4f..b8be503abde 100644
|
|
--- a/test/t/Makefile.am
|
|
+++ b/test/t/Makefile.am
|
|
@@ -132,6 +132,7 @@ EXTRA_DIST = \
|
|
test_dmypy.py \
|
|
test_dnssec_keygen.py \
|
|
test_dnsspoof.py \
|
|
+ test_doas.py \
|
|
test_dot.py \
|
|
test_dpkg.py \
|
|
test_dpkg_deb.py \
|
|
diff --git a/test/t/test_doas.py b/test/t/test_doas.py
|
|
new file mode 100644
|
|
index 00000000000..a8039c58608
|
|
--- /dev/null
|
|
+++ b/test/t/test_doas.py
|
|
@@ -0,0 +1,17 @@
|
|
+import pytest
|
|
+
|
|
+
|
|
+class TestDoas:
|
|
+ @pytest.mark.complete("doas -", require_cmd=True)
|
|
+ def test_1(self, completion):
|
|
+ assert completion
|
|
+
|
|
+ @pytest.mark.complete("doas cd foo", cwd="shared/default")
|
|
+ def test_2(self, completion):
|
|
+ assert completion == ".d/"
|
|
+ assert not completion.endswith(" ")
|
|
+
|
|
+ @pytest.mark.complete("doas sh share")
|
|
+ def test_3(self, completion):
|
|
+ assert completion == "d/"
|
|
+ assert not completion.endswith(" ")
|