Skip to content

Commit 64be5ea

Browse files
committed
feat(slabtop): new completion
1 parent a494a54 commit 64be5ea

File tree

5 files changed

+45
-0
lines changed

5 files changed

+45
-0
lines changed

completions/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ bashcomp_DATA = 2to3 \
395395
sha256sum \
396396
shellcheck \
397397
sitecopy \
398+
slabtop \
398399
_slackpkg \
399400
slapt-get \
400401
slapt-src \

completions/slabtop

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# bash completion for slabtop -*- shell-script -*-
2+
3+
_comp_cmd_slabtop()
4+
{
5+
local cur prev words cword comp_args
6+
_comp_initialize -- "$@" || return
7+
8+
local noargopts='!(-*|*[ds]*)'
9+
# shellcheck disable=SC2254
10+
case $prev in
11+
--help | --version | --delay | -${noargopts}[hVd])
12+
return
13+
;;
14+
--sort | -${noargopts}s)
15+
_comp_compgen_split -- "$(
16+
"$1" --help | command sed \
17+
-e '/^The following are valid sort criteria/,/^$/!d' \
18+
-ne 's/^[[:space:]]\(.\):.*/\1/p'
19+
)"
20+
return
21+
;;
22+
esac
23+
24+
if [[ $cur == -* ]]; then
25+
_comp_compgen_help
26+
return
27+
fi
28+
} &&
29+
complete -F _comp_cmd_slabtop slabtop
30+
31+
# ex: filetype=sh

test/t/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ EXTRA_DIST = \
560560
test_shar.py \
561561
test_shellcheck.py \
562562
test_sitecopy.py \
563+
test_slabtop.py \
563564
test_slackpkg.py \
564565
test_slapt_get.py \
565566
test_slapt_src.py \

test/t/test_slabtop.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import pytest
2+
3+
4+
class TestSlabtop:
5+
@pytest.mark.complete("slabtop --", require_cmd=True)
6+
def test_basic(self, completion):
7+
assert completion
8+
9+
@pytest.mark.complete("slabtop --sort ", require_cmd=True)
10+
def test_sort_arg(self, completion):
11+
assert completion

test/test-cmd-list.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ sha512sum
343343
shar
344344
shellcheck
345345
sitecopy
346+
slabtop
346347
slapt-get
347348
slapt-src
348349
smartctl

0 commit comments

Comments
 (0)