Skip to content

Commit

Permalink
feat(fprintd-*): new completions
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Nov 7, 2024
1 parent 3c3ab17 commit 8aa4914
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 0 deletions.
2 changes: 2 additions & 0 deletions completions/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
/filebucket
/firefox-esr
/_flask
/fprintd-list
/fprintd-verify
/freeciv-gtk2
/freeciv-gtk3
/freeciv-sdl
Expand Down
8 changes: 8 additions & 0 deletions completions/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ bashcomp_DATA = 2to3 \
firefox \
flake8 \
_flamegraph \
fprintd-delete \
fprintd-enroll \
freeciv \
freeciv-server \
function \
Expand Down Expand Up @@ -618,6 +620,8 @@ CLEANFILES = \
filebucket \
firefox-esr \
_flask \
fprintd-list \
fprintd-verify \
freeciv-gtk2 \
freeciv-gtk3 \
freeciv-sdl \
Expand Down Expand Up @@ -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 \
Expand Down
12 changes: 12 additions & 0 deletions completions/fprintd-delete
Original file line number Diff line number Diff line change
@@ -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
38 changes: 38 additions & 0 deletions completions/fprintd-enroll
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions test/t/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
10 changes: 10 additions & 0 deletions test/t/test_fprintd_delete.py
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions test/t/test_fprintd_enroll.py
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions test/t/test_fprintd_list.py
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions test/t/test_fprintd_verify.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions test/test-cmd-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ firefox
flake8
fmt
fold
fprintd-enroll
fprintd-verify
freeciv
freeciv-server
fusermount
Expand Down

0 comments on commit 8aa4914

Please sign in to comment.