diff --git a/completions/Makefile.am b/completions/Makefile.am index 9fbac97c67b..16e3a4fb057 100644 --- a/completions/Makefile.am +++ b/completions/Makefile.am @@ -300,6 +300,7 @@ cross_platform = 2to3 \ newlist \ newusers \ ngrep \ + nload \ nmap \ _nmcli \ _nox \ diff --git a/completions/nload b/completions/nload new file mode 100644 index 00000000000..370409b3e41 --- /dev/null +++ b/completions/nload @@ -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 diff --git a/test/t/Makefile.am b/test/t/Makefile.am index 8205e156286..303f49097eb 100644 --- a/test/t/Makefile.am +++ b/test/t/Makefile.am @@ -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 \ diff --git a/test/t/test_nload.py b/test/t/test_nload.py new file mode 100644 index 00000000000..9827333e7c7 --- /dev/null +++ b/test/t/test_nload.py @@ -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 diff --git a/test/test-cmd-list.txt b/test/test-cmd-list.txt index ff35ca15cd6..acb7622cbe6 100644 --- a/test/test-cmd-list.txt +++ b/test/test-cmd-list.txt @@ -243,6 +243,7 @@ newlist newusers ngrep nl +nload nm nmap nproc