From 3a2383a87e451dac7fd6c34beb20cdbf5e7a0ec5 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 1 Feb 2019 22:20:41 -0500 Subject: [PATCH] shovel: New completion --- completions/Makefile.am | 1 + completions/shovel | 22 ++++++++++++++++++++++ test/t/Makefile.am | 1 + test/t/test_shovel.py | 12 ++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 completions/shovel create mode 100644 test/t/test_shovel.py diff --git a/completions/Makefile.am b/completions/Makefile.am index be9b1a7ec25..c0fb9483a4e 100644 --- a/completions/Makefile.am +++ b/completions/Makefile.am @@ -363,6 +363,7 @@ bashcomp_DATA = 2to3 \ screen \ scrub \ sh \ + shovel \ sitecopy \ slackpkg \ slapt-get \ diff --git a/completions/shovel b/completions/shovel new file mode 100644 index 00000000000..4f5b030e93a --- /dev/null +++ b/completions/shovel @@ -0,0 +1,22 @@ +# shovel completion + +_shovel() +{ + local cur prev words cword + _init_completion || return + + case $prev in + --help|--version|-!(-*)[h]) + return + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help )' -- "$cur" ) ) + elif [[ -f shovel.py || -d shovel ]]; then + COMPREPLY=( $( compgen -W '$(shovel tasks | cut -s -d"#" -f1) help tasks' -- "$cur") ) + fi +} && +complete -F _shovel shovel + +# ex: filetype=sh diff --git a/test/t/Makefile.am b/test/t/Makefile.am index 8a67797f127..3d397b3dadd 100644 --- a/test/t/Makefile.am +++ b/test/t/Makefile.am @@ -524,6 +524,7 @@ EXTRA_DIST = \ test_sha1sum.py \ test_shar.py \ test_sh.py \ + test_shovel.py \ test_sitecopy.py \ test_slackpkg.py \ test_slapt_get.py \ diff --git a/test/t/test_shovel.py b/test/t/test_shovel.py new file mode 100644 index 00000000000..dbc87db1c8d --- /dev/null +++ b/test/t/test_shovel.py @@ -0,0 +1,12 @@ +import pytest + + +class TestShovel: + + @pytest.mark.complete("shovel ") + def test_1(self, completion): + assert completion + + @pytest.mark.complete("shovel --") + def test_2(self, completion): + assert completion