Skip to content

Commit 5feb285

Browse files
committed
refactor(pytest): generalize option choice arg parsing
1 parent 3eab73d commit 5feb285

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

completions/pytest

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# bash completion for pytest(1) -*- shell-script -*-
22

3+
_pytest_option_choice_args()
4+
{
5+
local modes=$("${2:-pytest}" $1=bash-competion-nonexistent 2>&1 |
6+
command sed -e 's/[^[:space:][:alnum:]-]\{1,\}//g' \
7+
-ne 's/.*choose from //p')
8+
COMPREPLY+=($(compgen -W '$modes' -- "$cur"))
9+
}
10+
311
_pytest()
412
{
513
local cur prev words cword split
@@ -78,10 +86,7 @@ _pytest()
7886
return
7987
;;
8088
--dist)
81-
local modes=$("$1" --dist=nonexistent-distmode 2>&1 |
82-
command sed -e 's/[^[:space:][:alnum:]-]\{1,\}//g' \
83-
-ne 's/.*choose from //p')
84-
COMPREPLY=($(compgen -W '$modes' -- "$cur"))
89+
_pytest_option_choice_args $prev "$1"
8590
return
8691
;;
8792
esac

0 commit comments

Comments
 (0)