diff --git a/completions/.gitignore b/completions/.gitignore index 20e68d0acc5..a382becd7f4 100644 --- a/completions/.gitignore +++ b/completions/.gitignore @@ -84,6 +84,8 @@ /filebucket /firefox-esr /_flask +/fprintd-list +/fprintd-verify /freeciv-gtk2 /freeciv-gtk3 /freeciv-sdl diff --git a/completions/Makefile.am b/completions/Makefile.am index 338f3044783..743141790fa 100644 --- a/completions/Makefile.am +++ b/completions/Makefile.am @@ -120,6 +120,8 @@ bashcomp_DATA = 2to3 \ firefox \ flake8 \ _flamegraph \ + fprintd-delete \ + fprintd-enroll \ freeciv \ freeciv-server \ function \ @@ -618,6 +620,8 @@ CLEANFILES = \ filebucket \ firefox-esr \ _flask \ + fprintd-list \ + fprintd-verify \ freeciv-gtk2 \ freeciv-gtk3 \ freeciv-sdl \ @@ -998,6 +1002,10 @@ symlinks: $(DATA) firefox-esr iceweasel mozilla-firefox $(ss) _flamegraph \ _watchexec + $(ss) fprintd-delete \ + fprintd-list + $(ss) fprintd-enroll \ + fprintd-verify $(ss) freeciv \ civclient freeciv-gtk2 freeciv-gtk3 freeciv-sdl freeciv-xaw $(ss) freeciv-server \ diff --git a/completions/fprintd-delete b/completions/fprintd-delete new file mode 100644 index 00000000000..bf1e7532868 --- /dev/null +++ b/completions/fprintd-delete @@ -0,0 +1,12 @@ +# bash completion for fprintd-delete and fprintd-list -*- shell-script -*- + +_comp_cmd_fprintd_delete() +{ + local cur prev words cword comp_args + _comp_initialize -- "$@" || return + + _comp_compgen_allowed_users +} && + complete -F _comp_cmd_fprintd_delete fprintd-delete fprintd-list + +# ex: filetype=sh diff --git a/completions/fprintd-enroll b/completions/fprintd-enroll new file mode 100644 index 00000000000..df3b450619d --- /dev/null +++ b/completions/fprintd-enroll @@ -0,0 +1,38 @@ +# bash completion for fprintd-enroll and fprintd-verify -*- shell-script -*- + +_comp_cmd_fprintd_enroll() +{ + local cur prev words cword comp_args + _comp_initialize -- "$@" || return + + local noargopts='!(-*|*[f]*)' + # shellcheck disable=SC2254 + case $prev in + --help | -h) + return + ;; + --finger | -${noargopts}f) + # Only -enroll may output a message with valid options in it + _comp_compgen_split -- "$( + "${1/-verify/-enroll}" --finger no-such-finger 2>&1 | + command sed \ + -e s/,//g -ne 's/^.*Name must be one of \(.*\)/\1/p' + )" + return + ;; + esac + + if [[ $cur == -* ]]; then + _comp_compgen_help + return + fi + + local REPLY + _comp_count_args -a "@(--finger|-${noargopts}[f])" + if ((REPLY == 1)); then + _comp_compgen_allowed_users + fi +} && + complete -F _comp_cmd_fprintd_enroll fprintd-enroll fprintd-verify + +# ex: filetype=sh diff --git a/test/t/Makefile.am b/test/t/Makefile.am index f7a297489b9..faec686a2bf 100644 --- a/test/t/Makefile.am +++ b/test/t/Makefile.am @@ -177,6 +177,10 @@ EXTRA_DIST = \ test_flake8.py \ test_fmt.py \ test_fold.py \ + test_fprintd_delete.py \ + test_fprintd_enroll.py \ + test_fprintd_list.py \ + test_fprintd_verify.py \ test_freebsd_update.py \ test_freeciv.py \ test_freeciv_server.py \ diff --git a/test/t/test_fprintd_delete.py b/test/t/test_fprintd_delete.py new file mode 100644 index 00000000000..25ae6d4408a --- /dev/null +++ b/test/t/test_fprintd_delete.py @@ -0,0 +1,10 @@ +import pytest + + +@pytest.mark.bashcomp( + cmd="fprintd-delete", +) +class TestFprintdDelete: + @pytest.mark.complete("fprintd-delete ") + def test_basic(self, completion): + assert completion diff --git a/test/t/test_fprintd_enroll.py b/test/t/test_fprintd_enroll.py new file mode 100644 index 00000000000..d5f941b220d --- /dev/null +++ b/test/t/test_fprintd_enroll.py @@ -0,0 +1,18 @@ +import pytest + + +@pytest.mark.bashcomp( + cmd="fprintd-enroll", +) +class TestFprintdEnroll: + @pytest.mark.complete("fprintd-enroll ") + def test_basic(self, completion): + assert completion + + @pytest.mark.complete("fprintd-enroll -", require_cmd=True) + def test_options(self, completion): + assert completion + + @pytest.mark.complete("fprintd-enroll --finger ", require_cmd=True) + def test_finger(self, completion): + assert completion diff --git a/test/t/test_fprintd_list.py b/test/t/test_fprintd_list.py new file mode 100644 index 00000000000..232d1cfee21 --- /dev/null +++ b/test/t/test_fprintd_list.py @@ -0,0 +1,10 @@ +import pytest + + +@pytest.mark.bashcomp( + cmd="fprintd-list", +) +class TestFprintdList: + @pytest.mark.complete("fprintd-list ") + def test_basic(self, completion): + assert completion diff --git a/test/t/test_fprintd_verify.py b/test/t/test_fprintd_verify.py new file mode 100644 index 00000000000..e9da3251cc6 --- /dev/null +++ b/test/t/test_fprintd_verify.py @@ -0,0 +1,14 @@ +import pytest + + +@pytest.mark.bashcomp( + cmd="fprintd-verify", +) +class TestFprintdVerify: + @pytest.mark.complete("fprintd-verify ") + def test_basic(self, completion): + assert completion + + @pytest.mark.complete("fprintd-verify -", require_cmd=True) + def test_options(self, completion): + assert completion diff --git a/test/test-cmd-list.txt b/test/test-cmd-list.txt index c16c9596766..ff35ca15cd6 100644 --- a/test/test-cmd-list.txt +++ b/test/test-cmd-list.txt @@ -101,6 +101,8 @@ firefox flake8 fmt fold +fprintd-enroll +fprintd-verify freeciv freeciv-server fusermount