Skip to content

Commit

Permalink
feat(nload): new completion
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Jan 2, 2025
1 parent 3201497 commit 85ccdfa
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions completions/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ cross_platform = 2to3 \
newlist \
newusers \
ngrep \
nload \
nmap \
_nmcli \
_nox \
Expand Down
28 changes: 28 additions & 0 deletions completions/nload
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# bash completion for nload(1) -*- shell-script -*-

_comp_cmd_nload()
{
local cur prev words cword comp_args
_comp_initialize -- "$@" || return

local noargopts='!(-*|*[aiotuU]*)'
case $prev in
--help | -${noargopts}[haiot])
return
;;
-${noargopts}[uU])
_comp_compgen -- -W 'h b k m g H B K M G'
return
;;
esac

if [[ $cur == -* ]]; then
_comp_compgen_help
return
fi

_comp_compgen_available_interfaces
} &&
complete -F _comp_cmd_nload nload

# ex: filetype=sh
1 change: 1 addition & 0 deletions test/t/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ EXTRA_DIST = \
test_newusers.py \
test_ngrep.py \
test_nl.py \
test_nload.py \
test_nm.py \
test_nmap.py \
test_nmcli.py \
Expand Down
11 changes: 11 additions & 0 deletions test/t/test_nload.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest


class TestNload:
@pytest.mark.complete("nload ")
def test_basic(self, completion):
assert completion

@pytest.mark.complete("nload -", require_cmd=True)
def test_options(self, completion):
assert completion
1 change: 1 addition & 0 deletions test/test-cmd-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ newlist
newusers
ngrep
nl
nload
nm
nmap
nproc
Expand Down

0 comments on commit 85ccdfa

Please sign in to comment.